Handle Space and Enter KeyDown event for About button (#1459)

This commit is contained in:
Hongxu Xu 2021-01-12 03:46:08 +08:00 committed by GitHub
parent cdcb95656d
commit f910d64d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -177,6 +177,7 @@
<muxc:NavigationViewItem x:Name="AboutButton"
x:Uid="AboutButton"
Style="{StaticResource NavViewItemStyle}"
KeyDown="OnAboutButtonKeyDown"
Tapped="OnAboutButtonClick">
<muxc:NavigationViewItem.Icon>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph="&#xe946;"/>

View File

@ -432,6 +432,14 @@ void MainPage::OnAboutButtonClick(Object ^ sender, ItemClickEventArgs ^ e)
ShowAboutPage();
}
void MainPage::OnAboutButtonKeyDown(Object ^ sender, KeyRoutedEventArgs ^ e)
{
if (e->Key == VirtualKey::Space || e->Key == VirtualKey::Enter)
{
ShowAboutPage();
}
}
void MainPage::OnAboutFlyoutOpened(_In_ Object ^ sender, _In_ Object ^ e)
{
// Keep Ignoring Escape till the About page flyout is opened

View File

@ -55,6 +55,7 @@ public
_In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e);
void OnAboutButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
void OnAboutButtonKeyDown(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
void OnAboutFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
void OnAboutFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
void AlwaysOnTopButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);