Adding automation names to buttons (#842)

* Add missing automation names for buttons in graphing calculator

* Add narrator support for tracing features
This commit is contained in:
Eric Wong 2019-12-04 11:00:07 -08:00 committed by GitHub
parent 133df73d6a
commit 36327b73de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 16 deletions

View File

@ -17,6 +17,7 @@ using namespace Windows::Foundation;
using namespace Windows::ApplicationModel; using namespace Windows::ApplicationModel;
using namespace Windows::UI::Text; using namespace Windows::UI::Text;
using namespace Windows::UI::Xaml; using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Automation;
using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Controls::Primitives; using namespace Windows::UI::Xaml::Controls::Primitives;
@ -50,8 +51,10 @@ void EquationTextBox::OnApplyTemplate()
auto toolTip = ref new ToolTip(); auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance(); auto resProvider = AppResourceProvider::GetInstance();
toolTip->Content = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip") : resProvider->GetResourceString(L"hideEquationButtonToolTip"); auto equationButtonMessage = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip") : resProvider->GetResourceString(L"hideEquationButtonToolTip");
toolTip->Content = equationButtonMessage;
ToolTipService::SetToolTip(m_equationButton, toolTip); ToolTipService::SetToolTip(m_equationButton, toolTip);
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
} }
if (m_kgfEquationButton != nullptr) if (m_kgfEquationButton != nullptr)
@ -191,9 +194,10 @@ void EquationTextBox::OnEquationButtonClicked(Object ^ sender, RoutedEventArgs ^
auto toolTip = ref new ToolTip(); auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance(); auto resProvider = AppResourceProvider::GetInstance();
toolTip->Content = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip") : resProvider->GetResourceString(L"hideEquationButtonToolTip"); auto equationButtonMessage = m_equationButton->IsChecked->Value ? resProvider->GetResourceString(L"showEquationButtonToolTip") : resProvider->GetResourceString(L"hideEquationButtonToolTip");
toolTip->Content = equationButtonMessage;
ToolTipService::SetToolTip(m_equationButton, toolTip); ToolTipService::SetToolTip(m_equationButton, toolTip);
AutomationProperties::SetName(m_equationButton, equationButtonMessage);
} }
void EquationTextBox::OnKGFEquationButtonClicked(Object ^ sender, RoutedEventArgs ^ e) void EquationTextBox::OnKGFEquationButtonClicked(Object ^ sender, RoutedEventArgs ^ e)

View File

@ -4128,47 +4128,75 @@
</data> </data>
<data name="equationAnalysisBack.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="equationAnalysisBack.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Back</value> <value>Back</value>
<comment>This is the tooltip contents for the back button in the equation analysis page in the graphing calculator</comment> <comment>This is the tooltip for the back button in the equation analysis page in the graphing calculator</comment>
</data>
<data name="equationAnalysisBack.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Back</value>
<comment>This is the automation name for the back button in the equation analysis page in the graphing calculator</comment>
</data> </data>
<data name="functionAnalysisButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="functionAnalysisButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Analyze equation</value> <value>Analyze equation</value>
<comment>This is the tooltip automation name for the analyze equation button</comment> <comment>This is the tooltip for the analyze equation button</comment>
</data>
<data name="functionAnalysisButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Analyze equation</value>
<comment>This is the automation name for the analyze equation button</comment>
</data> </data>
<data name="removeButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="removeButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Remove equation</value> <value>Remove equation</value>
<comment>This is the tool tip automation name for the graphing calculator remove equation buttons</comment> <comment>This is the tooltip for the graphing calculator remove equation buttons</comment>
</data>
<data name="removeButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Remove equation</value>
<comment>This is the automation name for the graphing calculator remove equation buttons</comment>
</data> </data>
<data name="shareButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="shareButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Share</value> <value>Share</value>
<comment>This is the tool tip automation name for the graphing calculator share button.</comment> <comment>This is the automation name for the graphing calculator share button.</comment>
</data>
<data name="shareButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Share</value>
<comment>This is the tooltip for the graphing calculator share button.</comment>
</data> </data>
<data name="colorChooserButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="colorChooserButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Change equation style</value> <value>Change equation style</value>
<comment>This is the tool tip automation name for the graphing calculator equation style button</comment> <comment>This is the tooltip for the graphing calculator equation style button</comment>
</data>
<data name="colorChooserButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Change equation style</value>
<comment>This is the automation name for the graphing calculator equation style button</comment>
</data> </data>
<data name="showEquationButtonToolTip" xml:space="preserve"> <data name="showEquationButtonToolTip" xml:space="preserve">
<value>Show</value> <value>Show</value>
<comment>This is the tooltip shown when visibility is set to hidden in the graphing calculator</comment> <comment>This is the tooltip/automation name shown when visibility is set to hidden in the graphing calculator</comment>
</data> </data>
<data name="hideEquationButtonToolTip" xml:space="preserve"> <data name="hideEquationButtonToolTip" xml:space="preserve">
<value>Hide</value> <value>Hide</value>
<comment>This is the tooltip shown when visibility is set to visible in the graphing calculator</comment> <comment>This is the tooltip/automation name shown when visibility is set to visible in the graphing calculator</comment>
</data> </data>
<data name="disableTracingButtonToolTip" xml:space="preserve"> <data name="disableTracingButtonToolTip" xml:space="preserve">
<value>Stop tracing</value> <value>Stop tracing</value>
<comment>This is the tool tip automation name for the graphing calculator stop tracing button</comment> <comment>This is the tooltip/automation name for the graphing calculator stop tracing button</comment>
</data> </data>
<data name="enableTracingButtonToolTip" xml:space="preserve"> <data name="enableTracingButtonToolTip" xml:space="preserve">
<value>Start tracing</value> <value>Start tracing</value>
<comment>This is the tool tip automation name for the graphing calculator start tracing button</comment> <comment>This is the tooltip/automation name for the graphing calculator start tracing button</comment>
</data> </data>
<data name="variablesButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="variablesButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Variables</value> <value>Variables</value>
<comment>This is the tool tip automation name for the Calculator variables button.</comment> <comment>This is the tooltip for the Calculator variables button.</comment>
</data>
<data name="variablesButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Variables</value>
<comment>This is the automation name for the Calculator variables button.</comment>
</data> </data>
<data name="sliderOptionsButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="sliderOptionsButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Configure slider</value> <value>Configure slider</value>
<comment>This is the tool tip text for teh slider options button in Graphing Calculator</comment> <comment>This is the tooltip text for the slider options button in Graphing Calculator</comment>
</data>
<data name="sliderOptionsButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Configure slider</value>
<comment>This is the automation name text for the slider options button in Graphing Calculator</comment>
</data> </data>
<data name="GraphSwitchToEquationMode" xml:space="preserve"> <data name="GraphSwitchToEquationMode" xml:space="preserve">
<value>Switch to equation mode</value> <value>Switch to equation mode</value>

View File

@ -687,6 +687,7 @@
<TranslateTransform x:Name="TraceValuePopupTransform"/> <TranslateTransform x:Name="TraceValuePopupTransform"/>
</Border.RenderTransform> </Border.RenderTransform>
<TextBlock x:Name="TraceValue" <TextBlock x:Name="TraceValue"
AutomationProperties.LiveSetting="Polite"
Foreground="{ThemeResource ToolTipForeground}" Foreground="{ThemeResource ToolTipForeground}"
Text="x=0,y=0"/> Text="x=0,y=0"/>
</Border> </Border>

View File

@ -38,6 +38,8 @@ using namespace Windows::System;
using namespace Windows::UI::Core; using namespace Windows::UI::Core;
using namespace Windows::UI::Input; using namespace Windows::UI::Input;
using namespace Windows::UI::Xaml; using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Automation;
using namespace Windows::UI::Xaml::Automation::Peers;
using namespace Windows::UI::Xaml::Data; using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Input;
@ -58,8 +60,10 @@ GraphingCalculator::GraphingCalculator()
auto toolTip = ref new ToolTip(); auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance(); auto resProvider = AppResourceProvider::GetInstance();
toolTip->Content = ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip"); auto tracingMessage = ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip");
toolTip->Content = tracingMessage;
ToolTipService::SetToolTip(ActiveTracing, toolTip); ToolTipService::SetToolTip(ActiveTracing, toolTip);
AutomationProperties::SetName(ActiveTracing, tracingMessage);
DataTransferManager ^ dataTransferManager = DataTransferManager::GetForCurrentView(); DataTransferManager ^ dataTransferManager = DataTransferManager::GetForCurrentView();
@ -156,6 +160,14 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationView
void GraphingCalculator::OnTracePointChanged(Windows::Foundation::Point newPoint) void GraphingCalculator::OnTracePointChanged(Windows::Foundation::Point newPoint)
{ {
TraceValue->Text = "(" + newPoint.X.ToString() + ", " + newPoint.Y.ToString() + ")"; TraceValue->Text = "(" + newPoint.X.ToString() + ", " + newPoint.Y.ToString() + ")";
auto peer = FrameworkElementAutomationPeer::FromElement(TraceValue);
if (peer != nullptr)
{
peer->RaiseAutomationEvent(AutomationEvents::LiveRegionChanged);
}
PositionGraphPopup(); PositionGraphPopup();
} }
@ -379,8 +391,10 @@ void GraphingCalculator::OnActiveTracingClick(Object ^ sender, RoutedEventArgs ^
auto toolTip = ref new ToolTip(); auto toolTip = ref new ToolTip();
auto resProvider = AppResourceProvider::GetInstance(); auto resProvider = AppResourceProvider::GetInstance();
toolTip->Content = ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip"); auto tracingMessage = ActiveTracingOn ? resProvider->GetResourceString(L"disableTracingButtonToolTip") : resProvider->GetResourceString(L"enableTracingButtonToolTip");
toolTip->Content = tracingMessage;
ToolTipService::SetToolTip(ActiveTracing, toolTip); ToolTipService::SetToolTip(ActiveTracing, toolTip);
AutomationProperties::SetName(ActiveTracing, tracingMessage);
} }
void GraphingCalculator::GraphingControl_LostFocus(Object ^ sender, RoutedEventArgs ^ e) void GraphingCalculator::GraphingControl_LostFocus(Object ^ sender, RoutedEventArgs ^ e)