From 6f69487829bf1e0d243e797404bae941e5572978 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 26 Jan 2022 17:14:01 -0600 Subject: [PATCH] Add a keyboard shortcut handler to the TabRowControl (#12260) This makes the scenario mentioned in #8480 work. It's maybe not as holistic a solution as we'd like, but it definitely works. Tested both with Narrator, and using the TabView scroll handles to get tab focus into the tab row manually * [x] Closing the _active_ tab with Ctrl+Shift+w works (not the `TabViewItem` that has focus, but that's how Edgium works so that seems fine) * [x] Opening a tab with Ctrl+Shift+t works * [x] Opening the cmdpal with Ctrl+Shift+p works * [x] Will take care of #8480 once we get the a11y team to validate * [x] I work here #### Notes: None of ```xaml PreviewKeyDown="_KeyDownHandler" KeyDown="_KeyDownHandler" KeyUp="_KeyDownHandler" ``` On the TerminalPage directly seem to fire when the focus is in the `TabViewItem` or the New Tab flyout. But they fire just fine when focus is in the `TermControl`. Interesting, because you'd think that the `TermControl` would have already handled the key... --- src/cascadia/TerminalApp/TabBase.cpp | 1 + src/cascadia/TerminalApp/TerminalPage.cpp | 6 ++++++ src/cascadia/TerminalApp/TerminalPage.xaml | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalApp/TabBase.cpp b/src/cascadia/TerminalApp/TabBase.cpp index ef17fe3eb95..3994a76c38f 100644 --- a/src/cascadia/TerminalApp/TabBase.cpp +++ b/src/cascadia/TerminalApp/TabBase.cpp @@ -251,4 +251,5 @@ namespace winrt::TerminalApp::implementation } }); } + } diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 1ef1087e2ae..6eb29cbfee8 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -1169,6 +1169,12 @@ namespace winrt::TerminalApp::implementation // Method Description: // - Called when the users pressed keyBindings while CommandPalette is open. + // - As of GH#8480, this is also bound to the TabRowControl's KeyUp event. + // That should only fire when focus is in the tab row, which is hard to + // do. Notably, that's possible: + // - When you have enough tabs to make the little scroll arrows appear, + // click one, then hit tab + // - When Narrator is in Scan mode (which is the a11y bug we're fixing here) // - This method is effectively an extract of TermControl::_KeyHandler and TermControl::_TryHandleKeyBinding. // Arguments: // - e: the KeyRoutedEventArgs containing info about the keystroke. diff --git a/src/cascadia/TerminalApp/TerminalPage.xaml b/src/cascadia/TerminalApp/TerminalPage.xaml index e4be0e54a06..ad2fe2a3257 100644 --- a/src/cascadia/TerminalApp/TerminalPage.xaml +++ b/src/cascadia/TerminalApp/TerminalPage.xaml @@ -21,7 +21,8 @@ + Grid.Row="0" + KeyUp="_KeyDownHandler" />