* Fixes to the Keyboard Handler to make it work better --

* drop keypress event (not used, registers as keydown in IE< which results
      in double events) 
    * return evt instead of evt.keyCode || evt.charCode, so apps can do
      whatever they like best
 * adjust ModifyFeature to new API
 * Adjust KeyboardDefaults to new API, and include a new set of keyCodes
    in switch statement to catch more cases
 * Include keyboard defaults test in list-tests.

Patch from tcoulter, work from Pedro Simonetti (See #1108), Paul Spencer,
myself. r=pagameba,me (Closes #1292)   


git-svn-id: http://svn.openlayers.org/trunk/openlayers@7644 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-07-31 17:45:16 +00:00
parent 3dcc30a24c
commit 09b4073636
6 changed files with 135 additions and 61 deletions

View File

@@ -93,7 +93,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* {Array(Integer)} Keycodes for deleting verticies. Set to null to disable
* vertex deltion by keypress. If non-null, keypresses with codes
* in this array will delete vertices under the mouse. Default
* is 46 and 100, the 'delete' and lowercase 'd' keys.
* is 46 and 68, the 'delete' and lowercase 'd' keys.
*/
deleteCodes: null,
@@ -183,7 +183,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
this.layer.style || this.layer.styleMap.createSymbolizer());
this.virtualStyle.fillOpacity = 0.3;
this.virtualStyle.strokeOpacity = 0.3;
this.deleteCodes = [46, 100];
this.deleteCodes = [46, 68];
this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
OpenLayers.Control.prototype.initialize.apply(this, [options]);
if(!(this.deleteCodes instanceof Array)) {
@@ -227,7 +227,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
// configure the keyboard handler
var keyboardOptions = {
keypress: this.handleKeypress
keydown: this.handleKeypress
};
this.handlers = {
keyboard: new OpenLayers.Handler.Keyboard(this, keyboardOptions)
@@ -517,7 +517,9 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Parameters:
* {Integer} Key code corresponding to the keypress event.
*/
handleKeypress: function(code) {
handleKeypress: function(evt) {
var code = evt.keyCode;
// check for delete key
if(this.feature &&
OpenLayers.Util.indexOf(this.deleteCodes, code) != -1) {