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-07-17 03:58:35 +0300
committerBret Johnson <bret.johnson@microsoft.com>2018-07-17 03:58:35 +0300
commitf12d33a0cbb67e657d7a9540073f44a910e9679b (patch)
tree27b34eae8f4e4561b3785c517e5ba33fb1f5af39
parent70d5fd26b2bdfac3f6a2b5162a30d04ad3b7ecb9 (diff)
[a11y][WPF] Fixed tree view to have proper narrator announced item num
-rw-r--r--Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs45
1 files changed, 37 insertions, 8 deletions
diff --git a/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs b/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs
index 4ca5c95e..2e010c4c 100644
--- a/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs
+++ b/Xwt.WPF/Xwt.WPFBackend/ExTreeViewItem.cs
@@ -1,4 +1,4 @@
-//
+//
// ExTreeViewItem.cs
//
// Author:
@@ -26,7 +26,10 @@
// THE SOFTWARE.
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Windows;
+using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Input;
using SWC = System.Windows.Controls;
@@ -230,12 +233,38 @@ namespace Xwt.WPFBackend
//We can't allow TreeViewItem(our base class) to get this message(OnGotFocus) because it will also select this item which we don't want
}
- private bool CtrlPressed
- {
- get
- {
- return Keyboard.IsKeyDown (WKey.RightCtrl) || Keyboard.IsKeyDown (WKey.LeftCtrl);
- }
- }
+ private bool CtrlPressed
+ {
+ get
+ {
+ return Keyboard.IsKeyDown (WKey.RightCtrl) || Keyboard.IsKeyDown (WKey.LeftCtrl);
+ }
+ }
+
+ protected override AutomationPeer OnCreateAutomationPeer ()
+ {
+ return new ExTreeViewItemAutomationPeer (this);
+ }
+
+ class ExTreeViewItemAutomationPeer : TreeViewItemAutomationPeer
+ {
+ public ExTreeViewItemAutomationPeer (ExTreeViewItem owner) : base (owner)
+ {
+ }
+
+ protected override List<AutomationPeer> GetChildrenCore ()
+ {
+ List<AutomationPeer> defaultChildren = base.GetChildrenCore ();
+ if (defaultChildren == null)
+ return null;
+
+ // We only want to include TreeView items in the a11y tree, not their constituent image/text/etc controls -
+ // for one thing including all controls messes up the "item 3 of 5" style counts announced by the
+ // narrator, as those controls would be included in the counts
+ List<AutomationPeer> children = defaultChildren.Where (
+ child => child is TreeViewItemAutomationPeer || child is TreeViewDataItemAutomationPeer).ToList ();
+ return children;
+ }
+ }
}
}