mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Fix issue 1782
This commit is contained in:
parent
6246d4fad8
commit
54c67a4f9e
2 changed files with 16 additions and 25 deletions
|
@ -323,14 +323,20 @@ namespace CalculatorApp
|
||||||
|
|
||||||
public static void DisableShortcuts(bool disable)
|
public static void DisableShortcuts(bool disable)
|
||||||
{
|
{
|
||||||
int viewId = Utilities.GetWindowId();
|
//deferredEnableShortcut is being used to prevent the mode change from happening before the user input has processed
|
||||||
|
if (s_keyHandlerCount > && !disable)
|
||||||
if (s_fDisableShortcuts.ContainsKey(viewId))
|
|
||||||
{
|
{
|
||||||
s_fDisableShortcuts[viewId] = disable;
|
s_deferredEnableShortcut = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int viewId = Utilities.GetWindowId();
|
||||||
|
if (s_fDisableShortcuts.ContainesKey(viewId))
|
||||||
|
{
|
||||||
|
s_fDisableShortcuts[viewId] = disable;
|
||||||
|
}
|
||||||
|
HonorShortcuts(!disable);
|
||||||
}
|
}
|
||||||
|
|
||||||
HonorShortcuts(!disable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateDropDownState(bool isOpen)
|
public static void UpdateDropDownState(bool isOpen)
|
||||||
|
@ -631,7 +637,6 @@ namespace CalculatorApp
|
||||||
private static void OnCharacterReceivedHandler(CoreWindow sender, CharacterReceivedEventArgs args)
|
private static void OnCharacterReceivedHandler(CoreWindow sender, CharacterReceivedEventArgs args)
|
||||||
{
|
{
|
||||||
int viewId = Utilities.GetWindowId();
|
int viewId = Utilities.GetWindowId();
|
||||||
|
|
||||||
bool hit = s_fHonorShortcuts.TryGetValue(viewId, out var currentHonorShortcuts);
|
bool hit = s_fHonorShortcuts.TryGetValue(viewId, out var currentHonorShortcuts);
|
||||||
|
|
||||||
if (!hit || currentHonorShortcuts)
|
if (!hit || currentHonorShortcuts)
|
||||||
|
@ -722,22 +727,9 @@ namespace CalculatorApp
|
||||||
s_keyHandlerCount--;
|
s_keyHandlerCount--;
|
||||||
if (s_keyHandlerCount == 0 && s_deferredEnableShortcut)
|
if (s_keyHandlerCount == 0 && s_deferredEnableShortcut)
|
||||||
{
|
{
|
||||||
KeyboardShortcutManager.DisableShortcuts(false);//shortcuts enabled
|
DisableShortcuts(false);
|
||||||
s_deferredEnableShortcut = false;
|
s_deferredEnableShortcut = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void TryEnableShortcut()
|
|
||||||
{
|
|
||||||
if (s_keyHandlerCount > 0)
|
|
||||||
{
|
|
||||||
s_deferredEnableShortcut = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KeyboardShortcutManager.DisableShortcuts(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnAcceleratorKeyActivated(CoreDispatcher dispatcher, AcceleratorKeyEventArgs args)
|
private static void OnAcceleratorKeyActivated(CoreDispatcher dispatcher, AcceleratorKeyEventArgs args)
|
||||||
|
@ -858,9 +850,8 @@ namespace CalculatorApp
|
||||||
//private static Concurrency.reader_writer_lock s_keyboardShortcutMapLock;
|
//private static Concurrency.reader_writer_lock s_keyboardShortcutMapLock;
|
||||||
private static readonly object s_keyboardShortcutMapLockMutex = new object();
|
private static readonly object s_keyboardShortcutMapLockMutex = new object();
|
||||||
|
|
||||||
|
private static int s_keyHandlerCount = 0;
|
||||||
private static int s_keyHandlerCount;
|
private static bool s_deferredEnableShortcut = false;
|
||||||
private static bool s_deferredEnableShortcut;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ namespace CalculatorApp
|
||||||
ViewMode newValue = m_model.Mode;
|
ViewMode newValue = m_model.Mode;
|
||||||
ViewMode previousMode = m_model.PreviousMode;
|
ViewMode previousMode = m_model.PreviousMode;
|
||||||
|
|
||||||
KeyboardShortcutManager.TryEnableShortcut();
|
KeyboardShortcutManager.DisableShortcuts(false);
|
||||||
|
|
||||||
if (newValue == ViewMode.Standard)
|
if (newValue == ViewMode.Standard)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue