Base 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.
OpenLayers. Handler | Base class to construct a higher-level handler for event sequences. |
Properties | |
control | {OpenLayers.Control}. |
keyMask | {Integer} Use bitwise operators and one or more of the OpenLayers.Handler constants to construct a keyMask. |
Constructor | |
OpenLayers. Handler | Construct a handler. |
Functions | |
activate | Turn on the handler. |
deactivate | Turn off the handler. |
Constants | |
OpenLayers. Handler. MOD_NONE | If set as the keyMask, <checkModifiers> returns false if any key is down. |
OpenLayers. Handler. MOD_SHIFT | If set as the keyMask, <checkModifiers> returns false if Shift is down. |
OpenLayers. Handler. MOD_CTRL | If set as the keyMask, <checkModifiers> returns false if Ctrl is down. |
OpenLayers. Handler. MOD_ALT | If set as the keyMask, <checkModifiers> returns false if Alt is down. |
{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.
{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.
// handler only responds if the Shift key is down handler.keyMask = OpenLayers.Handler.MOD_SHIFT; // handler only responds if Ctrl-Shift is down handler.keyMask = OpenLayers.Handler.MOD_SHIFT | OpenLayers.Handler.MOD_CTRL;
Construct a handler.
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. |
callbacks | {Object} An object whose properties correspond to abstracted events or sequences of browser events. The values for these properties are functions defined by the control that get called by the handler. |
options | {Object} An optional object whose properties will be set on the handler. |
If set as the keyMask, <checkModifiers> returns false if any key is down.
If set as the keyMask, <checkModifiers> returns false if Shift is down.
If set as the keyMask, <checkModifiers> returns false if Ctrl is down.
If set as the keyMask, <checkModifiers> returns false if Alt is down.
Turn on the handler.
activate: function()
Turn off the handler.
deactivate: function()