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.

    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

    An integer that identifies the created listener or null on failure. The identifier is required to remove the listener.

function cbPress(context) {    
    print("X: " + context.event_data.x.toString());

// Register a listener to log X coordinates on a layer to console
sb.addEventListener("", "Layer", cbPress);
Was this article helpful?
0 out of 0 found this helpful