[Event.buttonclick] make buttonclick work on RETURN/SPACE keydown
This commit is contained in:
@@ -20,6 +20,12 @@ OpenLayers.Event = {
|
||||
* element._eventCacheID
|
||||
*/
|
||||
observers: false,
|
||||
|
||||
/**
|
||||
* Constant: KEY_SPACE
|
||||
* {int}
|
||||
*/
|
||||
KEY_SPACE: 32,
|
||||
|
||||
/**
|
||||
* Constant: KEY_BACKSPACE
|
||||
@@ -388,7 +394,8 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
"mousedown", "mouseup", "mousemove",
|
||||
"click", "dblclick", "rightclick", "dblrightclick",
|
||||
"resize", "focus", "blur",
|
||||
"touchstart", "touchmove", "touchend"
|
||||
"touchstart", "touchmove", "touchend",
|
||||
"keydown"
|
||||
],
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({
|
||||
*/
|
||||
events: [
|
||||
'mousedown', 'mouseup', 'click', 'dblclick',
|
||||
'touchstart', 'touchmove', 'touchend'
|
||||
'touchstart', 'touchmove', 'touchend', 'keydown'
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -112,6 +112,18 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({
|
||||
element = element.parentNode;
|
||||
}
|
||||
if (OpenLayers.Element.hasClass(element, "olButton")) {
|
||||
if (evt.type === "keydown") {
|
||||
switch (evt.keyCode) {
|
||||
case OpenLayers.Event.KEY_RETURN:
|
||||
case OpenLayers.Event.KEY_SPACE:
|
||||
this.target.triggerEvent("buttonclick", {
|
||||
buttonElement: element
|
||||
});
|
||||
OpenLayers.Event.stop(evt);
|
||||
propagate = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.startEvt) {
|
||||
if (this.completeRegEx.test(evt.type)) {
|
||||
var pos = OpenLayers.Util.pagePosition(element);
|
||||
|
||||
Reference in New Issue
Block a user