Open context menu with context menu key

This commit is contained in:
Nathan Gray 2013-04-09 16:13:10 +00:00
parent 7219683699
commit 344bd88e4a
3 changed files with 25 additions and 2 deletions

View File

@ -202,6 +202,13 @@ function egwPopupActionImplementation()
} }
} }
// Menu button
if (_key.keyCode == EGW_KEY_MENU && !_key.ctrl)
{
return this.doExecuteImplementation({posx:0,posy:0}, _selected, _links, _target);
}
// Check whether the given shortcut exists // Check whether the given shortcut exists
var obj = this._searchShortcutInLinks(_key, _links); var obj = this._searchShortcutInLinks(_key, _links);
if (obj) if (obj)
@ -245,7 +252,7 @@ function egwPopupActionImplementation()
if (egwIsMobile()) { if (egwIsMobile()) {
$j(_node).bind('taphold', contextHandler); $j(_node).bind('taphold', contextHandler);
} else { } else {
_node.oncontextmenu = contextHandler; $j(_node).on('contextmenu', contextHandler);
} }
} }

View File

@ -72,6 +72,8 @@ var EGW_KEY_X = 88;
var EGW_KEY_Y = 89; var EGW_KEY_Y = 89;
var EGW_KEY_Z = 90; var EGW_KEY_Z = 90;
var EGW_KEY_MENU = 93;
var EGW_KEY_F1 = 112; var EGW_KEY_F1 = 112;
var EGW_KEY_F2 = 113; var EGW_KEY_F2 = 113;
var EGW_KEY_F3 = 114; var EGW_KEY_F3 = 114;
@ -88,7 +90,7 @@ var EGW_KEY_F12 = 123;
var EGW_VALID_KEYS = [ var EGW_VALID_KEYS = [
8, 9, 13, 27, 46, 32, 33, 34, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54, 8, 9, 13, 27, 46, 32, 33, 34, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 112, 113, 114, 115, 116, 117, 118, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 93, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 123 119, 120, 121, 122, 123
] ]
@ -173,6 +175,18 @@ $j(document).ready(function() {
}); });
}); });
/**
* Required to catch the context menu
*/
$j(window).on("contextmenu",document, function(event) {
if(egw_keyHandler(EGW_KEY_MENU, event.shiftKey, event.ctrlKey || event.metaKey, event.altKey))
{
// If the key handler successfully passed the key event to some
// sub component, prevent the default action
event.preventDefault();
}
});
/** /**
* Creates an unique key for the given shortcut * Creates an unique key for the given shortcut

View File

@ -24,6 +24,7 @@ function egwMenuImpl(_structure)
this.dhtmlxmenu = new dhtmlXMenuObject(); this.dhtmlxmenu = new dhtmlXMenuObject();
this.dhtmlxmenu.setSkin("egw"); this.dhtmlxmenu.setSkin("egw");
this.dhtmlxmenu.renderAsContextMenu(); this.dhtmlxmenu.renderAsContextMenu();
// TODO: Keyboard navigation of the menu
var self = this; var self = this;
@ -179,6 +180,7 @@ egwMenuImpl.prototype.showAt = function(_x, _y, _onHide)
var self = this; var self = this;
window.setTimeout(function() { window.setTimeout(function() {
self.dhtmlxmenu.showContextMenu(_x, _y); self.dhtmlxmenu.showContextMenu(_x, _y);
// TODO: Get keybard focus
}, 0); }, 0);
} }