From 34dff7e69c992687b29eebcd8b841eea4ebc2aea Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 15 Oct 2014 17:44:24 -0700 Subject: [PATCH] GUAC-890: Reset keyboard state after handling shortcut. Do not send client key events if a shortcut was handled. --- .../src/main/webapp/scripts/client-ui.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index 89e16225c..f6f0450e0 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -841,6 +841,7 @@ GuacUI.Client.KeyboardShortcut = function(pattern, onmatch) { * @param {Number} keysym The keysym which was either pressed or released. * @param {Boolean} pressed true if the keysym was pressed, false if the * keysym was released. + * @param {Boolean} true if the shortcut matched, false otherwise. */ this.update = function(keysym, pressed) { @@ -860,14 +861,20 @@ GuacUI.Client.KeyboardShortcut = function(pattern, onmatch) { keysymSet[keysym] = true; // Fire "match" event if the shortcut matches - if (guac_shortcut.onmatch && guac_shortcut.matches()) + if (guac_shortcut.onmatch && guac_shortcut.matches()) { guac_shortcut.onmatch(); + return true; + } + } // If not pressed, remove from set else delete keysymSet[keysym]; + // No match yet + return false; + }; /** @@ -875,9 +882,10 @@ GuacUI.Client.KeyboardShortcut = function(pattern, onmatch) { * the onmatch event is fired. * * @param {Number} keysym The keysym which was pressed. + * @param {Boolean} true if the shortcut matched, false otherwise. */ this.press = function(keysym) { - guac_shortcut.update(keysym, true); + return guac_shortcut.update(keysym, true); }; /** @@ -905,12 +913,17 @@ GuacUI.Client.KeyboardShortcut = function(pattern, onmatch) { * @param {Number} keysym The keysym which was either pressed or released. * @param {Boolean} pressed true if the keysym was pressed, false if the * keysym was released. + * @return true if any shortcut was matched and handled, false otherwise. */ GuacUI.Client.updateShortcuts = function(keysym, pressed) { + var shortcutHandled = false; + // Update tracking of registered shortcuts for (var i=0; i