Bloom.Edit.EditingView.AddMessageEventListener C# (CSharp) Method

AddMessageEventListener() public method

public AddMessageEventListener ( string eventName, Action action ) : void
eventName string
action Action
return void
        public void AddMessageEventListener(string eventName, Action<string> action)
        {
            _browser1.AddMessageEventListener(eventName, action);
        }

Usage Example

        /// <summary>
        /// For some reason, we need to call this code OnIdle.
        /// We couldn't figure out the timing any other way.
        /// Otherwise, sometimes the calledByCSharp object doesn't exist; then we don't call restoreAccordionSettings.
        /// If we don't call restoreAccordionSettings, then the more panel stays open without the checkboxes checked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnIdleAfterDocumentSupposedlyCompleted(object sender, EventArgs e)
        {
            System.Windows.Forms.Application.Idle -= OnIdleAfterDocumentSupposedlyCompleted;

            //Work-around for BL-422: https://jira.sil.org/browse/BL-422
            if (_currentlyDisplayedBook == null)
            {
                Debug.Fail(
                    "Debug Only: BL-422 reproduction (currentlyDisplayedBook was null in OnIdleAfterDocumentSupposedlyCompleted).");
                Logger.WriteEvent("BL-422 happened just now (currentlyDisplayedBook was null in OnIdleAfterDocumentSupposedlyCompleted).");
                return;
            }
            // listen for events raised by javascript
            _view.AddMessageEventListener("saveAccordionSettingsEvent", SaveAccordionSettings);
            _view.AddMessageEventListener("setModalStateEvent", SetModalState);
            _view.AddMessageEventListener("preparePageForEditingAfterOrigamiChangesEvent", PreparePageForEditingAfterOrigamiChanges);
        }