Fix deactivate and destroy methods on the keyboard handler. Add 28 tests for previously untested handler. Thanks to Erik for the quick review and comments - appreciated as always (closes #943).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4108 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-29 17:37:42 +00:00
parent eb65e9c2b3
commit e5641c76e0
3 changed files with 113 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {
* options - {Object} Optional object whose properties will be set on the
* handler.
*/
initialize: function () {
initialize: function(control, callbacks, options) {
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);
@@ -58,7 +58,7 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {
destroy: function() {
this.deactivate();
this.eventListener = null;
OpenLayers.Control.prototype.destroy.apply(this, arguments);
OpenLayers.Handler.prototype.destroy.apply(this, arguments);
},
/**
@@ -80,15 +80,15 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {
* Method: deactivate
*/
deactivate: function() {
var deactivated = false;
if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
for (var i = 0; i < this.KEY_EVENTS.length; i++) {
OpenLayers.Event.stopObserving(
document, this.KEY_EVENTS[i], this.eventListener);
window, this.KEY_EVENTS[i], this.eventListener);
}
return true;
} else {
return false;
deactivated = true;
}
return deactivated;
},
/**