mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Added KeyDown Event Handler for NavPane
This commit is contained in:
parent
fc6d1d4d54
commit
b24a784ece
3 changed files with 18 additions and 0 deletions
|
@ -168,6 +168,7 @@
|
||||||
PaneOpened="OnNavPaneOpened"
|
PaneOpened="OnNavPaneOpened"
|
||||||
PaneOpening="OnNavPaneOpening"
|
PaneOpening="OnNavPaneOpening"
|
||||||
SelectionChanged="OnNavSelectionChanged"
|
SelectionChanged="OnNavSelectionChanged"
|
||||||
|
KeyDown="OnNavPaneKeyDown"
|
||||||
TabIndex="1"
|
TabIndex="1"
|
||||||
UseSystemFocusVisuals="True"
|
UseSystemFocusVisuals="True"
|
||||||
IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
|
IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
|
||||||
|
|
|
@ -427,6 +427,22 @@ void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView ^ sender, _In_ Object ^
|
||||||
this->SetDefaultFocus();
|
this->SetDefaultFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainPage::OnNavPaneKeyDown(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e)
|
||||||
|
{
|
||||||
|
if (e->Key == VirtualKey::Space || e->Key == VirtualKey::Enter)
|
||||||
|
{
|
||||||
|
auto item = dynamic_cast<MUXC::NavigationViewItem ^>(FocusManager::GetFocusedElement());
|
||||||
|
if (item != nullptr && item->Name != L"About")
|
||||||
|
{
|
||||||
|
auto selectedItem = static_cast<NavCategory ^>(item->DataContext);
|
||||||
|
Model->Mode = selectedItem->Mode;
|
||||||
|
|
||||||
|
NavView->SelectedItem = item;
|
||||||
|
NavView->IsPaneOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainPage::OnAboutButtonClick(Object ^ sender, ItemClickEventArgs ^ e)
|
void MainPage::OnAboutButtonClick(Object ^ sender, ItemClickEventArgs ^ e)
|
||||||
{
|
{
|
||||||
ShowAboutPage();
|
ShowAboutPage();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public
|
||||||
void OnNavItemInvoked(
|
void OnNavItemInvoked(
|
||||||
Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/,
|
Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/,
|
||||||
_In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e);
|
_In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e);
|
||||||
|
void OnNavPaneKeyDown(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
|
||||||
|
|
||||||
void OnAboutButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ 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 OnAboutButtonKeyDown(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue