Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Once you have received an editor instance, you can register to events and get callbacks in the "OnEditorEvent" function:

...


function EditorLoaded(jsInterface)
{
    editor = frameWindow.editorObject;
    editor.AddListener("CursorChanged");
}

function OnEditorEvent(type,targetID)
{
    switch (type)
    {
        case "SelectedPageChanged":
            ShowSelectedPage();
            break;
        case "CursorChanged":
            alert("new cursor selected!");
            break;
    }
}

function ShowSelectedPage()
{
  pg = editor.GetSelectedPageName() + " / " + editor.GetNumPages();
  document.getElementById("pageDisplay").innerText = pg;
}

The "DocumentFullyLoaded", "SelectedPageChanged" and "DocumentSaved" events are always dispatched to the containing HTML page.

See You can listen to events using this method .addListener().

If using PublisherConnector

The first parameter takes an event name (string) and a callback function to be called when the event is fired off.

Code Block
await publisherConnector.addListener(
  "FrameMoveFinished", 
  target => console.log("Frame moved with id " + target)
);

If using the editorObject in Actions or the console

Code Block
window.OnEventListener = (event, target) => {
  if (event == "FrameMovedFinished") {
    console.log("Frame moved with id " + target)
  }
}

editorObject.AddListener("FrameMoveFinished");

See https://chilipublishdocs.atlassian.net/wiki/spaces/CPDOC/pages/1412202501/1413282Editor+Events for a list of all available events

...