mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 06:01:22 +00:00
GUAC-810: Inform text input UI when focus is needed.
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<!-- Text input -->
|
<!-- Text input -->
|
||||||
<div class="text-input-container" ng-show="showTextInput">
|
<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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@@ -28,7 +28,17 @@ angular.module('textInput').directive('guacTextInput', [function guacTextInput()
|
|||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
replace: true,
|
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',
|
templateUrl: 'app/textInput/templates/guacTextInput.html',
|
||||||
controller: ['$scope', '$rootScope', '$element', '$timeout',
|
controller: ['$scope', '$rootScope', '$element', '$timeout',
|
||||||
@@ -324,6 +334,16 @@ angular.module('textInput').directive('guacTextInput', [function guacTextInput()
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}, false);
|
}, 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
|
// If the text input UI has focus, prevent keydown events
|
||||||
$scope.$on('guacBeforeKeydown', function filterKeydown(event, keysym) {
|
$scope.$on('guacBeforeKeydown', function filterKeydown(event, keysym) {
|
||||||
if (hasFocus && !ALLOWED_KEYS[keysym])
|
if (hasFocus && !ALLOWED_KEYS[keysym])
|
||||||
|
Reference in New Issue
Block a user