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
This commit is contained in:
Stephanie Anderl 2020-04-24 15:46:37 -07:00 committed by GitHub
parent c2c92f4006
commit fcbea550c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,12 +52,11 @@ static map<int, bool> s_IsDropDownOpen;
static map<int, bool> s_ignoreNextEscape;
static map<int, bool> s_keepIgnoringEscape;
static map<int, bool> s_fHonorShortcuts;
static map<int, bool> s_fDisableShortcuts;
static map<int, Flyout ^> 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);
}