Creating Custom Event Handlers

Learn how to define own custom event handlers, which can be invoked by emitting events.


Custom Event Handlers

When the standard events exposed by various UI components such as "On Click" or "On Mouse Over" do not suffice, custom event handlers can be defined for any section, cell, or UI component.

Example: You may need to fetch and reload data in a widget, UI Repeater, or any other component. Alternatively, you may want to open or close a dialog box after an operation is performed or completed.


Steps:

  1. Right-click on the section, cell, or UI component to display the popup.

  2. Enter the custom event name in the Events text box and click "+".

    Add Custom Event

  3. The panel on the right displays the properties of the event handler. Click the pencil icon to edit the "Before Processing Script".

    Edit Before Processing Script

  4. Define the event handler in the edit panel.

    Edit Panel

  5. Navigate to UI Properties > Subscribe To Events, and subscribe to Global or Broadcast events. Multiple events can be subscribed to by adding commas in between.


Events emitted to a Parent or Child widget do not require subscription.

  1. In case of broadcast events emitted using sendMessage, subscribe to the messagereceived event and handle it as follows:

    if (eventData == "REFRESH") {
    app.emitEvent("statuschanged", eventData);
    } elseif (eventData == "CALLREFRESH") {
    app.emitEvent("statuschanged", eventData);
    app.emitEvent("updatecalls", eventData);
    } elseif (eventData == "STORYREFRESH") {
    app.emitEvent("storychanged", eventData);
    }