From bcbe57dec3267184d089c82d69730c3355f16389 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 20 Dec 2014 16:33:04 -0800 Subject: [PATCH] GUAC-810: Inform text input UI when focus is needed. --- .../webapp/app/client/templates/client.html | 2 +- .../app/textInput/directives/guacTextInput.js | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/guacamole/src/main/webapp/app/client/templates/client.html b/guacamole/src/main/webapp/app/client/templates/client.html index fd6fbc406..4528040d2 100644 --- a/guacamole/src/main/webapp/app/client/templates/client.html +++ b/guacamole/src/main/webapp/app/client/templates/client.html @@ -39,7 +39,7 @@
- +
diff --git a/guacamole/src/main/webapp/app/textInput/directives/guacTextInput.js b/guacamole/src/main/webapp/app/textInput/directives/guacTextInput.js index 66a04aa51..dc9600f12 100644 --- a/guacamole/src/main/webapp/app/textInput/directives/guacTextInput.js +++ b/guacamole/src/main/webapp/app/textInput/directives/guacTextInput.js @@ -28,7 +28,17 @@ angular.module('textInput').directive('guacTextInput', [function guacTextInput() return { restrict: 'E', replace: true, - scope: {}, + scope: { + + /** + * Whether the text input UI should have focus. Setting this value + * is not guaranteed to work, due to browser limitations. + * + * @type Boolean + */ + needsFocus : '=?' + + }, templateUrl: 'app/textInput/templates/guacTextInput.html', controller: ['$scope', '$rootScope', '$element', '$timeout', @@ -324,6 +334,16 @@ angular.module('textInput').directive('guacTextInput', [function guacTextInput() e.preventDefault(); }, false); + // Attempt to change focus depending on need + $scope.$watch('needsFocus', function focusDesireChanged(focusNeeded) { + + if (focusNeeded) + target.focus(); + else + target.blur(); + + }); + // If the text input UI has focus, prevent keydown events $scope.$on('guacBeforeKeydown', function filterKeydown(event, keysym) { if (hasFocus && !ALLOWED_KEYS[keysym])