mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
Enable keyboard accessibility for template and custom layout items (#7977)
This commit is contained in:
@@ -211,7 +211,10 @@
|
||||
<Border Margin="8"
|
||||
BorderBrush="{Binding Path=IsSelected, Converter={StaticResource BooleanToBrushConverter}}"
|
||||
Style="{StaticResource templateBackground}"
|
||||
MouseDown="LayoutItem_Click">
|
||||
MouseDown="LayoutItem_Click"
|
||||
Focusable="True"
|
||||
FocusManager.GotFocus="LayoutItem_Focused"
|
||||
KeyDown="LayoutItem_Apply">
|
||||
<DockPanel Margin="0,20,0,0"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Stretch"
|
||||
@@ -244,7 +247,10 @@
|
||||
<Border Margin="8"
|
||||
BorderBrush="{Binding Path=IsSelected, Converter={StaticResource BooleanToBrushConverter}}"
|
||||
Style="{StaticResource templateBackground}"
|
||||
MouseDown="LayoutItem_Click">
|
||||
MouseDown="LayoutItem_Click"
|
||||
Focusable="True"
|
||||
FocusManager.GotFocus="LayoutItem_Focused"
|
||||
KeyDown="LayoutItem_Apply">
|
||||
<DockPanel Margin="0,20,0,0"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
||||
@@ -84,6 +84,21 @@ namespace FancyZonesEditor
|
||||
Select(((Border)sender).DataContext as LayoutModel);
|
||||
}
|
||||
|
||||
private void LayoutItem_Focused(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Select(((Border)sender).DataContext as LayoutModel);
|
||||
}
|
||||
|
||||
private void LayoutItem_Apply(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Return || e.Key == Key.Space)
|
||||
{
|
||||
// When certain layout item (template or custom) is focused through keyboard and user
|
||||
// presses Enter or Space key, layout will be applied.
|
||||
Apply();
|
||||
}
|
||||
}
|
||||
|
||||
private void Select(LayoutModel newSelection)
|
||||
{
|
||||
if (EditorOverlay.Current.DataContext is LayoutModel currentSelection)
|
||||
@@ -154,6 +169,11 @@ namespace FancyZonesEditor
|
||||
}
|
||||
|
||||
private void Apply_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Apply();
|
||||
}
|
||||
|
||||
private void Apply()
|
||||
{
|
||||
EditorOverlay mainEditor = EditorOverlay.Current;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user