Constructors

  • Parameters

    • target: unknown

    Returns Events

Properties

listeners: Record<string, Function[]>

Property: listeners {Object} Hashtable of Array(Function): events listener functions

Methods

  • APIMethod: addEventType Deprecated. Any event can be triggered without adding it first.

    Parameters: eventName - {String}

    Parameters

    • eventName: string

    Returns void

  • Method: attachToElement

    Parameters: element - {HTMLDOMElement} a DOM element to attach browser events to

    Parameters

    • element: HTMLElement

    Returns void

  • Method: getMousePosition

    Parameters: evt - {Event}

    Returns: {<OpenLayers.Pixel>} The current xy coordinate of the mouse, adjusted for offsets

    Parameters

    Returns Pixel

  • Method: handleBrowserEvent Basically just a wrapper to the triggerEvent() function, but takes care to set a property 'xy' on the event with the current mouse position.

    Parameters: evt - {Event}

    Parameters

    Returns void

  • APIMethod: on Convenience method for registering listeners with a common scope. Internally, this method calls as shown in the examples below.

    Example use: (code) // register a single listener for the "loadstart" event events.on({"loadstart": loadStartListener});

    // this is equivalent to the following events.register("loadstart", undefined, loadStartListener);

    // register multiple listeners to be called with the same this object events.on({ "loadstart": loadStartListener, "loadend": loadEndListener, scope: object });

    // this is equivalent to the following events.register("loadstart", object, loadStartListener); events.register("loadend", object, loadEndListener); (end)

    Parameters: object - {Object}

    Parameters

    • object: any

    Returns void

  • APIMethod: register Register an event on the events object.

    When the event is triggered, the 'func' function will be called, in the context of 'obj'. Imagine we were to register an event, specifying an OpenLayers.Bounds Object as 'obj'. When the event is triggered, the context in the callback function will be our Bounds object. This means that within our callback function, we can access the properties and methods of the Bounds object through the "this" variable. So our callback could execute something like: : leftStr = "Left: " + this.left;

                  or
    

    : centerStr = "Center: " + this.getCenterLonLat();

    Parameters: type - {String} Name of the event to register obj - {Object} The object to bind the context to for the callback#. If no object is specified, default is the Events's 'object' property. func - {Function} The callback function. If no callback is specified, this function does nothing. priority - {Boolean|Object} If true, adds the new listener to the front of the events queue instead of to the end.

    Valid options for priority: extension - {Boolean} If true, then the event will be registered as extension event. Extension events are handled before all other events.

    Parameters

    • type: string
    • Optionalobj: any
    • Optionalfunc: (arg: any) => void
    • Optionalpriority: boolean | Object

    Returns void

  • APIMethod: registerPriority Same as register() but adds the new listener to the front of the events queue instead of to the end.

    TODO: get rid of this in 3.0 - Decide whether listeners should be
    called in the order they were registered or in reverse order.
    

    Parameters: type - {String} Name of the event to register obj - {Object} The object to bind the context to for the callback#. If no object is specified, default is the Events's 'object' property. func - {Function} The callback function. If no callback is specified, this function does nothing.

    Parameters

    • type: string
    • obj: any
    • func: Function

    Returns void

  • Method: remove Remove all listeners for a given event type. If type is not registered, does nothing.

    Parameters: type - {String}

    Parameters

    • type: string

    Returns void

  • APIMethod: triggerEvent Trigger a specified registered event.

    Parameters: type - {String} evt - {Event || Object} will be passed to the listeners.

    Returns: {Boolean} The last listener return. If a listener returns false, the chain of listeners will stop getting called.

    Parameters

    • type: string
    • Optionalevt: Event

    Returns boolean

  • APIMethod: un Convenience method for unregistering listeners with a common scope. Internally, this method calls as shown in the examples below.

    Example use: (code) // unregister a single listener for the "loadstart" event events.un({"loadstart": loadStartListener});

    // this is equivalent to the following events.unregister("loadstart", undefined, loadStartListener);

    // unregister multiple listeners with the same this object events.un({ "loadstart": loadStartListener, "loadend": loadEndListener, scope: object });

    // this is equivalent to the following events.unregister("loadstart", object, loadStartListener); events.unregister("loadend", object, loadEndListener); (end)

    Parameters

    • object: any

    Returns void

  • APIMethod: unregister

    Parameters: type - {String} obj - {Object} If none specified, defaults to this.object func - {Function} The callback function to unregister.

    Parameters

    • type: string
    • obj: any
    • func: (e: any) => void

    Returns void