OpenLayers. EventUtility functions for event handling. Summary | Utility functions for event handling. | | | | {Object} A hashtable cache of the event observers. | | | | | | | | | | | | | | | | | | | | | | | | Cross browser event element detection. | | Determine whether event was caused by a left click. | | Stops an event from propagating. | | | | | | 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. | | | | | | Cycle through all the element entries in the events cache and call stopObservingElement on each. | | | | | | {Array(String)} supported events | | | | {Object} Hashtable of Array(Function): events listener functions | | {Object} the code object issuing application events | | {DOMElement} the DOM element receiving browser events | | {Array(String)} list of support application events | | {Function} bound event handler attached to elements | | | | | | 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. | | | | Remove all listeners for a given event type. | | Trigger a specified registered event | | Basically just a wrapper to the triggerEvent() function, but takes care to set a property ‘xy’ on the event with the current mouse position. | | |
observers{Object} A hashtable cache of the event observers. Keyed by element._eventCacheID
elementCross browser event element detection. ParametersReturns{DOMElement} The element that caused the event
isLeftClickisLeftClick: function( | event | ) |
|
Determine whether event was caused by a left click. ParametersReturns{Boolean}
stopstop: function( | event, | | allowDefault | ) |
|
Stops an event from propagating. Parametersevent | {Event} | allowDefault | {Boolean} If true, we stop the event chain but still allow the default browser behaviour (text selection, radio-button clicking, etc) Default false |
findElementfindElement: function( | event, | | tagName | ) |
|
Parametersevent | {Event} | tagName | {String} |
Returns{DOMElement} The first node with the given tagName, starting from the node the event was triggered on and traversing the DOM upwards
observeobserve: function( | elementParam, | | name, | | observer, | | useCapture | ) |
|
ParameterselementParam | {DOMElement || String} | name | {String} | observer | {function} | useCapture | {Boolean} |
stopObservingElementstopObservingElement: function( | elementParam | ) |
|
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. parameterselementParam | {DOMElement || String} |
_removeElementObservers_removeElementObservers: function( | elementObservers | ) |
|
ParameterselementObservers | {Array(Object)} Array of (element, name, observer, usecapture) objects, taken directly from hashtable |
stopObservingstopObserving: function( | elementParam, | | name, | | observer, | | useCapture | ) |
|
ParameterselementParam | {DOMElement || String} | name | {String} | observer | {function} | useCapture | {Boolean} |
Returns{Boolean} Whether or not the event observer was removed
unloadCacheCycle through all the element entries in the events cache and call stopObservingElement on each.
OpenLayers. EventsSummary | | | {Array(String)} supported events | | | | {Object} Hashtable of Array(Function): events listener functions | | {Object} the code object issuing application events | | {DOMElement} the DOM element receiving browser events | | {Array(String)} list of support application events | | {Function} bound event handler attached to elements | | | | | | 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. | | | | Remove all listeners for a given event type. | | Trigger a specified registered event | | Basically just a wrapper to the triggerEvent() function, but takes care to set a property ‘xy’ on the event with the current mouse position. | | |
BROWSER_EVENTS{Array(String)} supported events
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
OpenLayers. EventsConstruct an OpenLayers.Events object. Parametersobject | {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? |
addEventTypeaddEventType: function( | eventName | ) |
|
Add a new event type to this events object. If the event type has already been added, do nothing. Parameters
attachToElementattachToElement: function ( | element | ) |
|
Parameterselement | {HTMLDOMElement} a DOM element to attach browser events to |
registerregister: 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();
Parameterstype | {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. |
registerPriorityregisterPriority: 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. |
Parameterstype | {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. |
unregisterunregister: function ( | type, | | obj, | | func | ) |
|
Parameterstype | {String} | obj | {Object} If none specified, defaults to this.object | func | {Function} |
removeRemove all listeners for a given event type. If type is not registered, does nothing. Parameters
triggerEventtriggerEvent: function ( | type, | | evt | ) |
|
Trigger a specified registered event Parameters
handleBrowserEventhandleBrowserEvent: function ( | 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. Parameters
getMousePositiongetMousePosition: function ( | evt | ) |
|
ParametersReturns {OpenLayers.Pixel} The current xy coordinate of the mouse, adjusted for offsets
|