sb.addEventListener(event, target, callback)
Add an event listener that will invoke a callback with the standard context object as its first argument. The target option can be used to specify a model object to listen on, if it is not present the listener will be created at the application level.
Parameters: event The string name of the event to listen for target An optional parameter containing the fully qualified name of a model object to listen on callback A JS function that is invoked with context as its first argument when the event fires Return: An integer that identifies the created listener or null on failure. The identifier is required to remove the listener.
Example: function cbPress(context) { print("X: " + context.event_data.x.toString()); } // Register a listener to log gre.press X coordinates on a layer to console sb.addEventListener("gre.press", "Layer", cbPress);