Skip to content

Commit 54d176c

Browse files
committed
Add keyboard accelerator to the search box
1 parent 569f072 commit 54d176c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
<RowDefinition Height="*" />
2222
</Grid.RowDefinitions>
2323
<SelectorBar Grid.Column="0" Grid.Row="0" x:Name="WindowSelector" SelectionChanged="WindowSelectionChanged" />
24-
<TextBox Grid.Column="1" Grid.Row="0" Height="32" Width="300" HorizontalAlignment="Right" VerticalContentAlignment="Center" x:Name="SearchBox" HorizontalContentAlignment="Right" TextChanged="SearchBox_TextChanged"></TextBox>
24+
<TextBox Grid.Column="1" Grid.Row="0" Height="32" Width="300" HorizontalAlignment="Right" VerticalContentAlignment="Center" x:Name="SearchBox" HorizontalContentAlignment="Right" TextChanged="SearchBox_TextChanged">
25+
<TextBox.KeyboardAccelerators>
26+
<KeyboardAccelerator Modifiers="Control" Key="F" Invoked="SearchBoy_KeyboardAcceleratorInvoked" />
27+
</TextBox.KeyboardAccelerators>
28+
</TextBox>
2529
<Button Grid.Column="2" Grid.Row="0" HorizontalContentAlignment="Center">
2630
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE713;" />
2731
</Button>

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.UI.Windowing;
1313
using Microsoft.UI.Xaml;
1414
using Microsoft.UI.Xaml.Controls;
15+
using Microsoft.UI.Xaml.Input;
1516
using ShortcutGuide.Models;
1617
using ShortcutGuide.Properties;
1718
using Windows.Foundation;
@@ -138,5 +139,10 @@ private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
138139
{
139140
ShortcutPageParameters.SearchFilter.OnFilterChanged(SearchBox.Text);
140141
}
142+
143+
private void SearchBoy_KeyboardAcceleratorInvoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
144+
{
145+
SearchBox.Focus(FocusState.Programmatic);
146+
}
141147
}
142148
}

0 commit comments

Comments
 (0)