Skip to content

Commit

Permalink
Polish AutomationProperties and UIA Tree Navigation (#4805)
Browse files Browse the repository at this point in the history
AutomationProperties of interest in this PR include...
- Name: the name of a UI element (generally used as the main identifier
  for it)
- HelpText: an additional description for a more complex UI element
- AccessibilityView[1]
  - Raw: hide from the UIA tree. Only navigate to this if you know what
    you're doing
  - Control: a control without any content in it. Basically, a point at
    which the user can make a decision as to how to navigate the tree or
    invoke an action.
  - Content: a control that also has content to present to the user.

I set a few more AutomationProperties throughout Windows Terminal...
- MinMaxClose Control: hidden (we can/should rely on the true buttons
  that we are hiding)
- SplitButton: Name and Help text (currently ignored due to #4804, but
  having it in the resource file won't cause any problems)
- SearchBox: added a more specific name to the close button
- BackgroundImage: hide it

## References
A few additional work items have been created for tracking...
- SplitButton: #4804

## PR Checklist
* [X] Closes #2099 
* [X] Closes #2102 

## Validation Steps Performed
Verified using Accessibility Insights and Inspect.exe

[1] https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-treeoverview
  • Loading branch information
msftbot[bot] authored Mar 5, 2020
1 parent 3953b71 commit 27342db
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 37 deletions.
24 changes: 18 additions & 6 deletions src/cascadia/TerminalApp/MinMaxCloseControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,37 @@ the MIT License. See LICENSE in the project root for license information. -->
</ResourceDictionary>
</StackPanel.Resources>

<Button Height="36.0" MinWidth="46.0" Width="46.0" x:Name="MinimizeButton" Style="{StaticResource CaptionButton}" Click="_MinimizeClick"
AutomationProperties.Name="Minimize">
<Button Height="36.0" MinWidth="46.0" Width="46.0"
x:Name="MinimizeButton"
x:Uid="WindowMinimizeButton"
Style="{StaticResource CaptionButton}"
Click="_MinimizeClick"
AutomationProperties.AccessibilityView="Raw">
<Button.Resources>
<ResourceDictionary>
<x:String x:Key="CaptionButtonPath">M 0 0 H 10</x:String>
</ResourceDictionary>
</Button.Resources>
</Button>
<Button Height="36.0" MinWidth="46.0" Width="46.0" x:Name="MaximizeButton" Style="{StaticResource CaptionButton}" Click="_MaximizeClick"
AutomationProperties.Name="Maximize">
<Button Height="36.0" MinWidth="46.0" Width="46.0"
x:Name="MaximizeButton"
x:Uid="WindowMaximizeButton"
Style="{StaticResource CaptionButton}"
Click="_MaximizeClick"
AutomationProperties.AccessibilityView="Raw">
<Button.Resources>
<ResourceDictionary>
<x:String x:Key="CaptionButtonPath">M 0 0 H 10 V 10 H 0 V 0</x:String>
<x:String x:Key="CaptionButtonPathWindowMaximized">M 0 2 h 8 v 8 h -8 v -8 M 2 2 v -2 h 8 v 8 h -2</x:String>
</ResourceDictionary>
</Button.Resources>
</Button>
<Button Height="36.0" MinWidth="46.0" Width="46.0" x:Name="CloseButton" Style="{StaticResource CaptionButton}" Click="_CloseClick"
AutomationProperties.Name="Close">
<Button Height="36.0" MinWidth="46.0" Width="46.0"
x:Name="CloseButton"
x:Uid="WindowCloseButton"
Style="{StaticResource CaptionButton}"
Click="_CloseClick"
AutomationProperties.AccessibilityView="Raw">
<Button.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
Expand Down
71 changes: 43 additions & 28 deletions src/cascadia/TerminalApp/Resources/Resources.language-en.resw
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -268,4 +268,19 @@ Temporarily using the Windows Terminal default settings.
<data name="CmdStartingDirArgDesc" xml:space="preserve">
<value>Open in the given directory instead of the profile's set startingDirectory</value>
</data>
</root>
<data name="NewTabSplitButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.HelpText" xml:space="preserve">
<value>Press the button to open a new terminal tab with your default profile. Open the flyout to select which profile you want to open.</value>
</data>
<data name="NewTabSplitButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>New Tab</value>
</data>
<data name="WindowCloseButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Close</value>
</data>
<data name="WindowMaximizeButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Maximize</value>
</data>
<data name="WindowMinimizeButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Minimize</value>
</data>
</root>
4 changes: 3 additions & 1 deletion src/cascadia/TerminalApp/TabRowControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ the MIT License. See LICENSE in the project root for license information. -->
<mux:TabView.TabStripFooter>
<mux:SplitButton
x:Name="NewTabButton"
x:Uid="NewTabSplitButton"
Click="OnNewTabButtonClick"
VerticalAlignment="Stretch"
HorizontalAlignment="Left"
Content="&#xE710;"
UseLayoutRounding="true"
FontFamily="Segoe MDL2 Assets"
FontWeight="SemiLight"
FontSize="12">
FontSize="12"
AutomationProperties.AccessibilityView="Control">
<!-- U+E710 is the fancy plus icon. -->
<mux:SplitButton.Resources>
<!-- Override the SplitButton* resources to match the tab view's button's styles. -->
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ namespace winrt::TerminalApp::implementation
WUX::Controls::IconSourceElement iconElement;
iconElement.IconSource(iconSource);
profileMenuItem.Icon(iconElement);
Automation::AutomationProperties::SetAccessibilityView(iconElement, Automation::Peers::AccessibilityView::Raw);
}

if (profile.GetGuid() == defaultProfileGuid)
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/lib/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <winrt/Windows.UI.Xaml.Hosting.h>
#include "winrt/Windows.UI.Xaml.Markup.h"
#include "winrt/Windows.UI.Xaml.Documents.h"
#include "winrt/Windows.UI.Xaml.Automation.h"
#include <winrt/Windows.ApplicationModel.DataTransfer.h>

#include <winrt/Microsoft.Toolkit.Win32.UI.XamlHost.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,7 @@
<value>terminal</value>
<comment>The type of control that the terminal ahderes to. Used to identify how a user can interact with this kind of control.</comment>
</data>
<data name="SearchBox_Close.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Close Search Box</value>
</data>
</root>
3 changes: 2 additions & 1 deletion src/cascadia/TerminalControl/TSFInputControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
d:DesignHeight="768"
d:DesignWidth="1024">

<Canvas x:Name="Canvas" Visibility="Collapsed">
<Canvas x:Name="Canvas"
Visibility="Collapsed">
<TextBlock x:Name="TextBlock"
IsTextSelectionEnabled="false"
TextDecorations="Underline" />
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalControl/TermControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
-->

<Grid x:Name="RootGrid">
<Image x:Name="BackgroundImage" />
<Image x:Name="BackgroundImage"
AutomationProperties.AccessibilityView="Raw" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
Expand Down

0 comments on commit 27342db

Please sign in to comment.