loleaflet: hide context menu after pressing ESC key

This commit is contained in:
Andras Timar
2016-06-10 23:42:11 +02:00
parent ec15d9e9ff
commit 445f97a0c7

View File

@ -44,6 +44,7 @@ L.Control.ContextMenu = L.Control.extend({
map.on('locontextmenu', this._onContextMenu, this);
map.on('mousedown', this._onMouseDown, this);
map.on('keydown', this._onKeyDown, this);
},
_onMouseDown: function(e) {
@ -52,6 +53,12 @@ L.Control.ContextMenu = L.Control.extend({
$.contextMenu('destroy', '.leaflet-layer');
},
_onKeyDown: function(e) {
if (e.originalEvent.keyCode === 27 /* ESC */) {
$.contextMenu('destroy', '.leaflet-layer');
}
},
_onContextMenu: function(obj) {
if (!map._editlock) {
return;