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