Fix the captured access key in the result box

* Fix issue #1782

* Fixed issue 1782

* Fix issue 1782

* Fix issue #1782

* Fix Issue #1782

Co-authored-by: Jesus Baylon <t-jbaylon@microsoft.com>
This commit is contained in:
jbaylon3 2022-06-13 19:03:40 -07:00 committed by GitHub
parent 410dce76bf
commit 6430551167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -249,6 +249,7 @@ internal static void Initialize()
var coreWindow = Window.Current.CoreWindow;
coreWindow.CharacterReceived += OnCharacterReceivedHandler;
coreWindow.KeyDown += OnKeyDownHandler;
coreWindow.KeyUp += OnKeyUpHandler;
coreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated;
KeyboardShortcutManager.RegisterNewAppViewId();
}
@ -322,14 +323,20 @@ public static void HonorShortcuts(bool allow)
public static void DisableShortcuts(bool disable)
{
int viewId = Utilities.GetWindowId();
if (s_fDisableShortcuts.ContainsKey(viewId))
//deferredEnableShortcut is being used to prevent the mode change from happening before the user input has processed
if (s_keyHandlerCount > 0 && !disable)
{
s_fDisableShortcuts[viewId] = disable;
s_deferredEnableShortcut = true;
}
else
{
int viewId = Utilities.GetWindowId();
if (s_fDisableShortcuts.ContainsKey(viewId))
{
s_fDisableShortcuts[viewId] = disable;
}
HonorShortcuts(!disable);
}
HonorShortcuts(!disable);
}
public static void UpdateDropDownState(bool isOpen)
@ -644,6 +651,8 @@ private static void OnCharacterReceivedHandler(CoreWindow sender, CharacterRecei
private static void OnKeyDownHandler(CoreWindow sender, KeyEventArgs args)
{
s_keyHandlerCount++;
if (args.Handled)
{
return;
@ -714,6 +723,16 @@ private static void OnKeyDownHandler(CoreWindow sender, KeyEventArgs args)
}
}
private static void OnKeyUpHandler(CoreWindow sender, KeyEventArgs args)
{
s_keyHandlerCount--;
if (s_keyHandlerCount == 0 && s_deferredEnableShortcut)
{
DisableShortcuts(false);
s_deferredEnableShortcut = false;
}
}
private static void OnAcceleratorKeyActivated(CoreDispatcher dispatcher, AcceleratorKeyEventArgs args)
{
if (args.KeyStatus.IsKeyReleased)
@ -831,6 +850,9 @@ private static void Insert<Tkey, TValue>(SortedDictionary<Tkey, List<TValue>> de
//private static Concurrency.reader_writer_lock s_keyboardShortcutMapLock;
private static readonly object s_keyboardShortcutMapLockMutex = new object();
private static int s_keyHandlerCount = 0;
private static bool s_deferredEnableShortcut = false;
}
}
}