Merge vector-2.4 branch back to trunk.
svn merge sandbox/vector-2.4/@2307 sandbox/vector-2.4/@HEAD trunk/openlayers/ git-svn-id: http://svn.openlayers.org/trunk/openlayers@2803 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
59
lib/OpenLayers/Handler/Keyboard.js
Normal file
59
lib/OpenLayers/Handler/Keyboard.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* Handler for dragging a rectangle across the map. Keyboard is displayed
|
||||
* on mouse down, moves on mouse move, and is finished on mouse up.
|
||||
*
|
||||
* @class
|
||||
* @requires OpenLayers/Handler.js
|
||||
* @requires OpenLayers/Events.js
|
||||
*/
|
||||
OpenLayers.Handler.Keyboard = OpenLayers.Class.create();
|
||||
OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
|
||||
|
||||
/* http://www.quirksmode.org/js/keys.html explains key x-browser
|
||||
key handling quirks in pretty nice detail */
|
||||
|
||||
/* supported named callbacks are: keyup, keydown, keypress */
|
||||
|
||||
/** constant */
|
||||
KEY_EVENTS: ["keydown", "keypress", "keyup"],
|
||||
|
||||
/** @type Function
|
||||
* @private
|
||||
*/
|
||||
eventListener: null,
|
||||
|
||||
initialize: function () {
|
||||
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
||||
// cache the bound event listener method so it can be unobserved later
|
||||
this.eventListener = this.handleKeyEvent.bindAsEventListener(this);
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
OpenLayers.Handler.prototype.activate.apply(this, arguments);
|
||||
for (var i = 0; i < this.KEY_EVENTS.length; i++) {
|
||||
OpenLayers.Event.observe(
|
||||
window, this.KEY_EVENTS[i], this.eventListener);
|
||||
}
|
||||
},
|
||||
|
||||
deactivate: function() {
|
||||
OpenLayers.Handler.prototype.activate.apply(this, arguments);
|
||||
for (var i = 0; i < this.KEY_EVENTS.length; i++) {
|
||||
OpenLayers.Event.stopObserving(
|
||||
document, this.KEY_EVENTS[i], this.eventListener);
|
||||
}
|
||||
},
|
||||
|
||||
handleKeyEvent: function (evt) {
|
||||
if (this.checkModifiers(evt)) {
|
||||
this.callback(evt.type, [evt.charCode || evt.keyCode]);
|
||||
}
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Handler.Keyboard"
|
||||
});
|
||||
Reference in New Issue
Block a user