OpenLayers JavaScript Mapping Library |
OpenLayers. HandlerBase class to construct a higher-level handler for event sequences. All handlers have activate and deactivate methods. In addition, they have methods named like browser events. When a handler is activated, any additional methods named like a browser event is registered as a listener for the corresponding event. When a handler is deactivated, those same methods are unregistered as event listeners. Handlers also typically have a callbacks object with keys named like the abstracted events or event sequences that they are in charge of handling. The controls that wrap handlers define the methods that correspond to these abstract events - so instead of listening for individual browser events, they only listen for the abstract events defined by the handler. Handlers are created by controls, which ultimately have the responsibility of making changes to the the state of the application. Handlers themselves may make temporary changes, but in general are expected to return the application in the same state that they found it. Summary
control{OpenLayers.Control}. The control that initialized this handler. The control is assumed to have a valid map property - that map is used in the handler’s own setMap method. keyMask{Integer} Use bitwise operators and one or more of the OpenLayers.Handler constants to construct a keyMask. The keyMask is used by checkModifiers. If the keyMask matches the combination of keys down on an event, checkModifiers returns true. Example// handler only responds if the Shift key is down OpenLayers. HandlerConstruct a handler. Parameters
callback
Trigger the control’s named callback with the given arguments Parameters
setEvent
With each registered browser event, the handler sets its own evt property. This property can be accessed by controls if needed to get more information about the event that the handler is processing. This allows modifier keys on the event to be checked (alt, shift, and ctrl cannot be checked with the keyboard handler). For a control to determine which modifier keys are associated with the event that a handler is currently processing, it should access (code)handler.evt.altKey || handler.evt.shiftKey || handler.evt.ctrlKey(end). Parameters
OpenLayers. Handler. MOD_NONEIf set as the keyMask, checkModifiers returns false if any key is down. OpenLayers. Handler. MOD_SHIFTIf set as the keyMask, checkModifiers returns false if Shift is down. OpenLayers. Handler. MOD_CTRLIf set as the keyMask, checkModifiers returns false if Ctrl is down. OpenLayers. Handler. MOD_ALTIf set as the keyMask, checkModifiers returns false if Alt is down. |
setMap: function ( map )
Check the keyMask on the handler.
checkModifiers: function ( evt )
Turn on the handler.
activate: function()
Turn off the handler.
deactivate: function()
Trigger the control’s named callback with the given arguments
callback: function ( name, args )
register an event on the map
register: function ( name, method )
unregister an event from the map
unregister: function ( name, method )
With each registered browser event, the handler sets its own evt property.
setEvent: function( evt )
Deconstruct the handler.
destroy: function ()