Utility functions for event handling.
| OpenLayers. Event | Utility functions for event handling. |
| Properties | |
| observers | {Object} A hashtable cache of the event observers. |
| 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} |
| Functions | |
| element | Cross browser event element detection. |
| isLeftClick | Determine whether event was caused by a left click. |
| stop | Stops an event from propagating. |
| findElement | |
| observe | |
| stopObservingElement | Given the id of an element to stop observing, cycle through the element’s cached observers, calling stopObserving on each one, skipping those entries which can no longer be removed. |
| _removeElementObservers | |
| stopObserving | |
| unloadCache | Cycle through all the element entries in the events cache and call stopObservingElement on each. |
| OpenLayers. Events | |
| Constants | |
| BROWSER_EVENTS | {Array(String)} supported events |
| Properties | |
| listeners | {Object} Hashtable of Array(Function): events listener functions |
| object | {Object} the code object issuing application events |
| element | {DOMElement} the DOM element receiving browser events |
| eventTypes | {Array(String)} list of support application events |
| eventHandler | {Function} bound event handler attached to elements |
| fallThrough | {Boolean} |
| Constructor | |
| OpenLayers. Events | Construct an OpenLayers.Events object. |
| Functions | |
| destroy | |
| addEventType | Add a new event type to this events object. |
| attachToElement | |
| on | Convenience method for registering listeners with a common scope. |
| register | Register an event on the events object. |
| registerPriority | Same as register() but adds the new listener to the front of the events queue instead of to the end. |
| un | Convenience method for unregistering listeners with a common scope. |
| unregister | |
| remove | Remove all listeners for a given event type. |
| triggerEvent | Trigger a specified registered event. |
| 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. |
| getMousePosition |
| Constants | |
| BROWSER_EVENTS | {Array(String)} supported events |
| Properties | |
| listeners | {Object} Hashtable of Array(Function): events listener functions |
| object | {Object} the code object issuing application events |
| element | {DOMElement} the DOM element receiving browser events |
| eventTypes | {Array(String)} list of support application events |
| eventHandler | {Function} bound event handler attached to elements |
| fallThrough | {Boolean} |
| Constructor | |
| OpenLayers. Events | Construct an OpenLayers.Events object. |
| Functions | |
| destroy | |
| addEventType | Add a new event type to this events object. |
| attachToElement | |
| on | Convenience method for registering listeners with a common scope. |
| register | Register an event on the events object. |
| registerPriority | Same as register() but adds the new listener to the front of the events queue instead of to the end. |
| un | Convenience method for unregistering listeners with a common scope. |
| unregister | |
| remove | Remove all listeners for a given event type. |
| triggerEvent | Trigger a specified registered event. |
| 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. |
| getMousePosition |
Construct an OpenLayers.Events object.
| 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? |
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();
| 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: 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.0 | Decide whether listeners should be called in the order they were registered or in reverse order. |
| 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. |
getMousePosition: function ( evt )
| evt | {Event} |
{OpenLayers.Pixel} The current xy coordinate of the mouse, adjusted for offsets
Cross browser event element detection.
element: function( event )
Determine whether event was caused by a left click.
isLeftClick: function( event )
Stops an event from propagating.
stop: function( event, allowDefault )
findElement: function( event, tagName )
observe: function( elementParam, name, observer, useCapture )
Given the id of an element to stop observing, cycle through the element’s cached observers, calling stopObserving on each one, skipping those entries which can no longer be removed.
stopObservingElement: function( elementParam )
_removeElementObservers: function( elementObservers )
stopObserving: function( elementParam, name, observer, useCapture )
Cycle through all the element entries in the events cache and call stopObservingElement on each.
unloadCache: function()
destroy: function ()
Add a new event type to this events object.
addEventType: function( eventName )
attachToElement: function ( element )
Convenience method for registering listeners with a common scope.
on: function( object )
Register an event on the events object.
register: function ( type, obj, func )
Same as register() but adds the new listener to the front of the events queue instead of to the end.
registerPriority: function ( type, obj, func )
Convenience method for unregistering listeners with a common scope.
un: function( object )
unregister: function ( type, obj, func )
Remove all listeners for a given event type.
remove: function( type )
Trigger a specified registered event.
triggerEvent: function ( type, evt )
Basically just a wrapper to the triggerEvent() function, but takes care to set a property ‘xy’ on the event with the current mouse position.
handleBrowserEvent: function ( evt )
getMousePosition: function ( evt )