Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBret Johnson <bret.johnson@microsoft.com>2018-06-25 19:10:32 +0300
committerBret Johnson <bret.johnson@microsoft.com>2018-06-25 19:10:32 +0300
commitee5cdc65ec1319828aae38632092206156a6a7c3 (patch)
tree3ca39e09d4e36de28158ad67118fb466cae0141d
parent9e7b2905f6936d846b4d17231b00a73f09ecee1f (diff)
[a11y][WPF] Fix accessibility focus handling for spin buttons
Previously, if a spin button had the focus, the narrator wouldn't see it. We also reported to automation clients that spin buttons weren't focusable. This fixes both of those issues. Now the spin button having the focus is treated basically the same as the text box inside the spinner control having the focus, as it's the text box that gets focus when the user tabs to it.
-rw-r--r--Xwt.WPF/Xwt.WPFBackend/WindowsSpinButton.xaml.cs42
1 files changed, 34 insertions, 8 deletions
diff --git a/Xwt.WPF/Xwt.WPFBackend/WindowsSpinButton.xaml.cs b/Xwt.WPF/Xwt.WPFBackend/WindowsSpinButton.xaml.cs
index 9c6d41fe..361b91b4 100644
--- a/Xwt.WPF/Xwt.WPFBackend/WindowsSpinButton.xaml.cs
+++ b/Xwt.WPF/Xwt.WPFBackend/WindowsSpinButton.xaml.cs
@@ -1,4 +1,4 @@
-//
+//
// WindowsSpinButton.cs
//
// Author:
@@ -157,7 +157,7 @@ namespace Xwt.WPFBackend
#region General
Grid mainGrid;
- TextBox textBox;
+ SpinButtonTextBox textBox;
RepeatButton buttonUp;
RepeatButton buttonDown;
public WindowsSpinButton()
@@ -168,8 +168,8 @@ namespace Xwt.WPFBackend
mainGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
mainGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(16) });
- //Textbox
- textBox = new TextBox();
+ //Textbox
+ textBox = new SpinButtonTextBox (this);
textBox.Text = "0";
textBox.HorizontalAlignment = HorizontalAlignment.Stretch;
textBox.MinWidth = 25;
@@ -247,8 +247,9 @@ namespace Xwt.WPFBackend
}
}
+ public TextBox TextBox => textBox;
- private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
UpdateTextbox();
}
@@ -458,9 +459,19 @@ namespace Xwt.WPFBackend
#endregion
#region Accessibility
- protected override AutomationPeer OnCreateAutomationPeer ()
- {
- return new WindowsSpinButtonAutomationPeer (this);
+ class SpinButtonTextBox : TextBox
+ {
+ WindowsSpinButton spinButton;
+
+ public SpinButtonTextBox (WindowsSpinButton spinButton)
+ {
+ this.spinButton = spinButton;
+ }
+
+ protected override AutomationPeer OnCreateAutomationPeer ()
+ {
+ return new WindowsSpinButtonAutomationPeer (spinButton);
+ }
}
class WindowsSpinButtonAutomationPeer : UserControlAutomationPeer, IRangeValueProvider
@@ -486,6 +497,21 @@ namespace Xwt.WPFBackend
return AutomationControlType.Spinner;
}
+ protected override bool IsKeyboardFocusableCore ()
+ {
+ return true;
+ }
+
+ protected override bool HasKeyboardFocusCore ()
+ {
+ return Button.TextBox.IsFocused;
+ }
+
+ protected override void SetFocusCore ()
+ {
+ Button.TextBox.Focus ();
+ }
+
public override object GetPattern (PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.RangeValue) {