OpenLayers. Event

Utility functions for event handling.

Summary
Utility functions for event handling.
{int}
{int}
{int}
{int}
{int}
{int}
{int}
{int}
{int}
{Array(String)} supported events
{Boolean}
Construct an OpenLayers.Events object.
Add a new event type to this events object.
Register an event on the events object.
Same as register() but adds the new listener to the front of the events queue instead of to the end.
Trigger a specified registered event

Constants

KEY_BACKSPACE

{int}

KEY_TAB

{int}

KEY_RETURN

{int}

KEY_ESC

{int}

KEY_LEFT

{int}

KEY_UP

{int}

KEY_RIGHT

{int}

KEY_DOWN

{int}

KEY_DELETE

{int}

OpenLayers. Events

Summary
{Array(String)} supported events
{Boolean}
Construct an OpenLayers.Events object.
Add a new event type to this events object.
Register an event on the events object.
Same as register() but adds the new listener to the front of the events queue instead of to the end.
Trigger a specified registered event

Constants

BROWSER_EVENTS

{Array(String)} supported events

Properties

fallThrough

{Boolean}

Constructor

OpenLayers. Events

Construct an OpenLayers.Events object.

Parameters

object{Object} The js object to which this Events object is being
added element{DOMElement} A dom element to respond to browser events
eventTypes{Array(String)} Array of custom application events
fallThrough{Boolean} Allow events to fall through after these have been handled?

Functions

destroy

destroy: function ()

addEventType

addEventType: function(eventName)

Add a new event type to this events object.  If the event type has already been added, do nothing.

Parameters

eventName{String}

register

register: function (type,
obj,
func)

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.

registerPriority

registerPriority: function (type,
obj,
func)

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.0Decide 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.

unregister

unregister: function (type,
obj,
func)

Parameters

type{String}
obj{Object} If none specified, defaults to this.object
func{Function}

triggerEvent

triggerEvent: function (type,
evt)

Trigger a specified registered event

Parameters

type{String}
evt{Event}
destroy: function ()
addEventType: function(eventName)
Add a new event type to this events object.
register: function (type,
obj,
func)
Register an event on the events object.
registerPriority: function (type,
obj,
func)
Same as register() but adds the new listener to the front of the events queue instead of to the end.
unregister: function (type,
obj,
func)
triggerEvent: function (type,
evt)
Trigger a specified registered event