From b8a660068f2b4fe345fd39ca9bfaf96167d72a02 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 13 Jul 2021 12:02:06 +0300 Subject: [PATCH] Hint Manager: add timer, disable processing of other shortcuts when hints are visible --- apps/common/main/lib/component/HintManager.js | 9 ++++++++- apps/common/main/lib/core/keymaster.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/component/HintManager.js b/apps/common/main/lib/component/HintManager.js index 7102b883d..0010918b2 100644 --- a/apps/common/main/lib/component/HintManager.js +++ b/apps/common/main/lib/component/HintManager.js @@ -60,7 +60,8 @@ Common.UI.HintManager = new(function() { _currentHints = [], _inputLetters = '', _isComplete = false, - _isLockedKeyEvents = false; + _isLockedKeyEvents = false, + _inputTimer; var _api; @@ -96,6 +97,11 @@ Common.UI.HintManager = new(function() { _currentHints.forEach(function(item) { item.show(); }); + _inputTimer = setInterval(function () { + if (_inputLetters.length > 0) { + _inputLetters = ''; + } + }, 5000); } else { _hintVisible = false; } @@ -106,6 +112,7 @@ Common.UI.HintManager = new(function() { _currentHints && _currentHints.forEach(function(item) { item.hide() }); + clearInterval(_inputTimer); }; var _nextLevel = function() { diff --git a/apps/common/main/lib/core/keymaster.js b/apps/common/main/lib/core/keymaster.js index f6d05de70..4feedd4a0 100644 --- a/apps/common/main/lib/core/keymaster.js +++ b/apps/common/main/lib/core/keymaster.js @@ -71,6 +71,8 @@ var key, handler, k, i, modifiersMatch, scope; key = event.keyCode; + if (key !== 27 && Common.UI.HintManager.isHintVisible()) return; + if (index(_downKeys, key) == -1) { _downKeys.push(key); } @@ -105,8 +107,6 @@ for(k in _mods) if((!_mods[k] && index(handler.mods, +k) > -1) || (_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false; - if (modifiersMatch) - Common.NotificationCenter.trigger('hints:clear'); // call the handler and stop the event if neccessary if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){ if(locked===true || handler.locked || handler.method(event, handler)===false){