Give handlers a non-API evt property - this to be used by other controls in the library only. Eventually, we may decide to restructure this. (Closes #902)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4062 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -72,6 +72,16 @@ OpenLayers.Handler = OpenLayers.Class({
|
||||
* {Boolean}
|
||||
*/
|
||||
active: false,
|
||||
|
||||
/**
|
||||
* Property: evt
|
||||
* {Event} This property references the last event handled by the handler.
|
||||
* Note that this property is not part of the stable API. Use of the
|
||||
* evt property should be restricted to controls in the library
|
||||
* or other applications that are willing to update with changes to
|
||||
* the OpenLayers code.
|
||||
*/
|
||||
evt: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Handler
|
||||
@@ -198,7 +208,8 @@ OpenLayers.Handler = OpenLayers.Class({
|
||||
*/
|
||||
register: function (name, method) {
|
||||
// TODO: deal with registerPriority in 3.0
|
||||
this.map.events.registerPriority(name, this, method);
|
||||
this.map.events.registerPriority(name, this, method);
|
||||
this.map.events.registerPriority(name, this, this.setEvent);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -207,6 +218,29 @@ OpenLayers.Handler = OpenLayers.Class({
|
||||
*/
|
||||
unregister: function (name, method) {
|
||||
this.map.events.unregister(name, this, method);
|
||||
this.map.events.unregister(name, this, this.setEvent);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: 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:
|
||||
* evt - {Event} The browser event.
|
||||
*/
|
||||
setEvent: function(evt) {
|
||||
this.evt = evt;
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user