From 344bd88e4ac75345f666f822849b42cd422e514b Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 9 Apr 2013 16:13:10 +0000 Subject: [PATCH] Open context menu with context menu key --- phpgwapi/js/egw_action/egw_action_popup.js | 9 ++++++++- phpgwapi/js/egw_action/egw_keymanager.js | 16 +++++++++++++++- phpgwapi/js/egw_action/egw_menu_dhtmlx.js | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/phpgwapi/js/egw_action/egw_action_popup.js b/phpgwapi/js/egw_action/egw_action_popup.js index 5739945263..97844d0df2 100644 --- a/phpgwapi/js/egw_action/egw_action_popup.js +++ b/phpgwapi/js/egw_action/egw_action_popup.js @@ -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 var obj = this._searchShortcutInLinks(_key, _links); if (obj) @@ -245,7 +252,7 @@ function egwPopupActionImplementation() if (egwIsMobile()) { $j(_node).bind('taphold', contextHandler); } else { - _node.oncontextmenu = contextHandler; + $j(_node).on('contextmenu', contextHandler); } } diff --git a/phpgwapi/js/egw_action/egw_keymanager.js b/phpgwapi/js/egw_action/egw_keymanager.js index e2b2c70237..ca2d6eae8a 100644 --- a/phpgwapi/js/egw_action/egw_keymanager.js +++ b/phpgwapi/js/egw_action/egw_keymanager.js @@ -72,6 +72,8 @@ var EGW_KEY_X = 88; var EGW_KEY_Y = 89; var EGW_KEY_Z = 90; +var EGW_KEY_MENU = 93; + var EGW_KEY_F1 = 112; var EGW_KEY_F2 = 113; var EGW_KEY_F3 = 114; @@ -88,7 +90,7 @@ var EGW_KEY_F12 = 123; var EGW_VALID_KEYS = [ 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, - 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 ] @@ -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 diff --git a/phpgwapi/js/egw_action/egw_menu_dhtmlx.js b/phpgwapi/js/egw_action/egw_menu_dhtmlx.js index 546409c223..38b6c9a6d6 100644 --- a/phpgwapi/js/egw_action/egw_menu_dhtmlx.js +++ b/phpgwapi/js/egw_action/egw_menu_dhtmlx.js @@ -24,6 +24,7 @@ function egwMenuImpl(_structure) this.dhtmlxmenu = new dhtmlXMenuObject(); this.dhtmlxmenu.setSkin("egw"); this.dhtmlxmenu.renderAsContextMenu(); + // TODO: Keyboard navigation of the menu var self = this; @@ -179,6 +180,7 @@ egwMenuImpl.prototype.showAt = function(_x, _y, _onHide) var self = this; window.setTimeout(function() { self.dhtmlxmenu.showContextMenu(_x, _y); + // TODO: Get keybard focus }, 0); }