From 7612b69949d69d4e9699f41cc68cf59b6a6af8d9 Mon Sep 17 00:00:00 2001 From: Stephanie Anderl <46726333+sanderl@users.noreply.github.com> Date: Tue, 14 Apr 2020 12:37:00 -0700 Subject: [PATCH] Add Automation Names to the GraphNumPad (#1145) * Turn off keyboard shortcuts when in graphing mode * Added automation names to the graphnumpad, added any missing ones to the resources.resw file * Remove HonorShortcuts call in the EquationInputArea, update Equal button automation name to use the existing one * conditionally set the HonorShortcuts when the nav menu is closed * added disable shortcuts to override HonorShortcuts when it is set --- .../Common/KeyboardShortcutManager.cpp | 13 ++++ .../Common/KeyboardShortcutManager.h | 1 + src/Calculator/Resources/en-US/Resources.resw | 44 +++++++++-- .../EquationInputArea.xaml.cpp | 4 - .../GraphingCalculator/GraphingNumPad.xaml | 74 +++++++++++++++++++ src/Calculator/Views/MainPage.xaml.cpp | 9 ++- 6 files changed, 132 insertions(+), 13 deletions(-) diff --git a/src/Calculator/Common/KeyboardShortcutManager.cpp b/src/Calculator/Common/KeyboardShortcutManager.cpp index 59d98a83..f05e3c48 100644 --- a/src/Calculator/Common/KeyboardShortcutManager.cpp +++ b/src/Calculator/Common/KeyboardShortcutManager.cpp @@ -56,6 +56,8 @@ static map s_AboutFlyout; static reader_writer_lock s_keyboardShortcutMapLock; +static bool s_shortcutsDisabled = false; + namespace CalculatorApp { namespace Common @@ -735,6 +737,11 @@ 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); @@ -828,3 +835,9 @@ void KeyboardShortcutManager::OnWindowClosed(int viewId) s_fHonorShortcuts.erase(viewId); s_AboutFlyout.erase(viewId); } + +void KeyboardShortcutManager::DisableShortcuts(bool disable) +{ + s_shortcutsDisabled = disable; + HonorShortcuts(!disable); +} diff --git a/src/Calculator/Common/KeyboardShortcutManager.h b/src/Calculator/Common/KeyboardShortcutManager.h index 124ae167..32ace85b 100644 --- a/src/Calculator/Common/KeyboardShortcutManager.h +++ b/src/Calculator/Common/KeyboardShortcutManager.h @@ -43,6 +43,7 @@ namespace CalculatorApp static void IgnoreEscape(bool onlyOnce); static void HonorEscape(); static void HonorShortcuts(bool allow); + static void DisableShortcuts(bool disable); static void UpdateDropDownState(bool); static void ShiftButtonChecked(bool checked); static void UpdateDropDownState(Windows::UI::Xaml::Controls::Flyout ^ aboutPageFlyout); diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index 46cfce4e..7b5acc97 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -3539,6 +3539,10 @@ Inequalities Displayed on the button that contains a flyout for the inequality functions. + + Inequalities + Screen reader prompt for the Inequalities button + Bitwise Displayed on the button that contains a flyout for the bitwise functions in programmer mode. @@ -3843,14 +3847,6 @@ Graphing Name of the Graphing mode of the Calculator app. Displayed in the navigation menu. - - = - {Locked}This is the character that should trigger this button. Note that it is a character and not a key, so it does not come from the Windows::System::VirtualKey enum. - - - Equals - Screen reader prompt for the equal button on the graphing calculator operator keypad - Enter {Locked}This is the value from the VirtualKey enum that maps to this button @@ -4614,4 +4610,36 @@ Function Analysis Equation Box This is the automation name text for the equation box in the function analsis panel + + Less than + Screen reader prompt for the Less than button + + + Less than or equal + Screen reader prompt for the Less than or equal button + + + Equal + Screen reader prompt for the Equal button + + + Greater than or equal + Screen reader prompt for the Greater than or equal button + + + Greater than + Screen reader prompt for the Greater than button + + + X + Screen reader prompt for the X button on the graphing calculator operator keypad + + + Y + Screen reader prompt for the Y button on the graphing calculator operator keypad + + + Submit + Screen reader prompt for the submit button on the graphing calculator operator keypad + diff --git a/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml.cpp b/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml.cpp index ceaf8b18..f10fa534 100644 --- a/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml.cpp +++ b/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml.cpp @@ -125,8 +125,6 @@ void EquationInputArea::AddNewEquation() void EquationInputArea::EquationTextBox_GotFocus(Object ^ sender, RoutedEventArgs ^ e) { - KeyboardShortcutManager::HonorShortcuts(false); - auto eq = GetViewModelFromEquationTextBox(sender); if (eq != nullptr) { @@ -136,8 +134,6 @@ void EquationInputArea::EquationTextBox_GotFocus(Object ^ sender, RoutedEventArg void EquationInputArea::EquationTextBox_LostFocus(Object ^ sender, RoutedEventArgs ^ e) { - KeyboardShortcutManager::HonorShortcuts(true); - auto eq = GetViewModelFromEquationTextBox(sender); if (eq != nullptr) { diff --git a/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml b/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml index fb925f4e..2e4e7f91 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml +++ b/src/Calculator/Views/GraphingCalculator/GraphingNumPad.xaml @@ -393,6 +393,7 @@ causing the shortcut keys to be used when the control would normally be disabled. --> Mode; ViewMode previousMode = m_model->PreviousMode; + KeyboardShortcutManager::DisableShortcuts(false); + if (newValue == ViewMode::Standard) { EnsureCalculator(); @@ -171,6 +173,7 @@ void MainPage::OnAppPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows else if (newValue == ViewMode::Graphing) { EnsureGraphingCalculator(); + KeyboardShortcutManager::DisableShortcuts(true); } else if (NavCategory::IsConverterViewMode(newValue)) { @@ -424,7 +427,11 @@ void MainPage::OnNavPaneOpened(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args) { - KeyboardShortcutManager::HonorShortcuts(true); + if (Model->Mode != ViewMode::Graphing) + { + KeyboardShortcutManager::HonorShortcuts(true); + } + this->SetDefaultFocus(); }