From fcbea550c8786b4e663223fc10cd54e6ffe8d30e Mon Sep 17 00:00:00 2001 From: Stephanie Anderl <46726333+sanderl@users.noreply.github.com> Date: Fri, 24 Apr 2020 15:46:37 -0700 Subject: [PATCH] Fixed issue where Shortcuts were still enabled in Graphing Mode (#1196) * Fixed DisableShortcuts to disable per the specfic view id and fixed the issue where honorshortcuts did not set the value properly * Updated the condition to always set the honor shortcuts to false if disable shortcuts is true --- .../Common/KeyboardShortcutManager.cpp | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Calculator/Common/KeyboardShortcutManager.cpp b/src/Calculator/Common/KeyboardShortcutManager.cpp index f05e3c48..3ce05d15 100644 --- a/src/Calculator/Common/KeyboardShortcutManager.cpp +++ b/src/Calculator/Common/KeyboardShortcutManager.cpp @@ -52,12 +52,11 @@ static map s_IsDropDownOpen; static map s_ignoreNextEscape; static map s_keepIgnoringEscape; static map s_fHonorShortcuts; +static map s_fDisableShortcuts; static map s_AboutFlyout; static reader_writer_lock s_keyboardShortcutMapLock; -static bool s_shortcutsDisabled = false; - namespace CalculatorApp { namespace Common @@ -737,11 +736,6 @@ void KeyboardShortcutManager::UpdateDropDownState(Flyout ^ aboutPageFlyout) void KeyboardShortcutManager::HonorShortcuts(bool allow) { - if (s_shortcutsDisabled) - { - return; - } - // Writer lock for the static maps reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock); @@ -749,6 +743,15 @@ void KeyboardShortcutManager::HonorShortcuts(bool allow) if (s_fHonorShortcuts.find(viewId) != s_fHonorShortcuts.end()) { + if (s_fDisableShortcuts.find(viewId) != s_fDisableShortcuts.end()) + { + if (s_fDisableShortcuts[viewId]) + { + s_fHonorShortcuts[viewId] = false; + return; + } + } + s_fHonorShortcuts[viewId] = allow; } } @@ -808,6 +811,7 @@ void KeyboardShortcutManager::RegisterNewAppViewId() s_ignoreNextEscape[appViewId] = false; s_keepIgnoringEscape[appViewId] = false; s_fHonorShortcuts[appViewId] = true; + s_fDisableShortcuts[appViewId] = false; s_AboutFlyout[appViewId] = nullptr; } @@ -833,11 +837,18 @@ void KeyboardShortcutManager::OnWindowClosed(int viewId) s_ignoreNextEscape.erase(viewId); s_keepIgnoringEscape.erase(viewId); s_fHonorShortcuts.erase(viewId); + s_fDisableShortcuts.erase(viewId); s_AboutFlyout.erase(viewId); } void KeyboardShortcutManager::DisableShortcuts(bool disable) { - s_shortcutsDisabled = disable; + int viewId = Utils::GetWindowId(); + + if (s_fDisableShortcuts.find(viewId) != s_fDisableShortcuts.end()) + { + s_fDisableShortcuts[viewId] = disable; + } + HonorShortcuts(!disable); }