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-11 21:12:17 +0300
committerBret Johnson <bret.johnson@microsoft.com>2018-07-11 21:12:17 +0300
commit70d5fd26b2bdfac3f6a2b5162a30d04ad3b7ecb9 (patch)
tree0cad39e7aa98d35b22b78b74f2c5a7f9b4bff2a1
parent973c6d3eb93dede6887b7b673b5dfac54d13283e (diff)
[a11y][WPF] Added ability to set popover initial keyboard focus
-rw-r--r--Xwt.WPF/Xwt.WPFBackend/PopoverBackend.cs19
1 files changed, 18 insertions, 1 deletions
diff --git a/Xwt.WPF/Xwt.WPFBackend/PopoverBackend.cs b/Xwt.WPF/Xwt.WPFBackend/PopoverBackend.cs
index afedab29..a4a3c2a4 100644
--- a/Xwt.WPF/Xwt.WPFBackend/PopoverBackend.cs
+++ b/Xwt.WPF/Xwt.WPFBackend/PopoverBackend.cs
@@ -28,6 +28,7 @@ using System;
using Xwt.Backends;
using System.Windows.Media;
using System.Windows;
+using System.Windows.Input;
namespace Xwt.WPFBackend
{
@@ -54,6 +55,13 @@ namespace Xwt.WPFBackend
get; set;
}
+ /// <summary>
+ /// Control, if any, that should get the initial keyboard focus when the popover is shown.
+ /// The control should be inside the popover, but it doesn't necessarily have to be an Xwt
+ /// managed widget.
+ /// </summary>
+ public UIElement InitialFocus { get; set; }
+
new Popover Frontend {
get { return (Popover)base.frontend; }
}
@@ -104,6 +112,7 @@ namespace Xwt.WPFBackend
Placement = System.Windows.Controls.Primitives.PlacementMode.Custom,
StaysOpen = false,
};
+ NativeWidget.Opened += NativeWidget_Opened;
NativeWidget.Closed += NativeWidget_Closed;
}
@@ -142,6 +151,12 @@ namespace Xwt.WPFBackend
}
}
+ void NativeWidget_Opened (object sender, EventArgs e)
+ {
+ if (InitialFocus != null)
+ InitialFocus.Focus ();
+ }
+
void NativeWidget_Closed (object sender, EventArgs e)
{
Border.Child = null;
@@ -156,8 +171,10 @@ namespace Xwt.WPFBackend
public void Dispose ()
{
- if (NativeWidget != null)
+ if (NativeWidget != null) {
+ NativeWidget.Opened -= NativeWidget_Opened;
NativeWidget.Closed -= NativeWidget_Closed;
+ }
}
}
} \ No newline at end of file