GUAC-810: Inform text input UI when focus is needed.

This commit is contained in:
Michael Jumper
2014-12-20 16:33:04 -08:00
parent a89101acaf
commit bcbe57dec3
2 changed files with 22 additions and 2 deletions

View File

@@ -39,7 +39,7 @@
<!-- Text input -->
<div class="text-input-container" ng-show="showTextInput">
<guac-text-input></guac-text-input>
<guac-text-input needs-focus="showTextInput"></guac-text-input>
</div>
</div>

View File

@@ -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])