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 <kbd>Ctrl+Shift+w</kbd> works (not the `TabViewItem` that has focus, but that's how Edgium works so that seems fine)
* [x] Opening a tab with <kbd>Ctrl+Shift+t</kbd> works
* [x] Opening the cmdpal with <kbd>Ctrl+Shift+p</kbd> 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...
This commit is contained in:
Mike Griese
2022-01-26 17:14:01 -06:00
committed by GitHub
parent d89c241dac
commit 6f69487829
3 changed files with 9 additions and 1 deletions

View File

@@ -251,4 +251,5 @@ namespace winrt::TerminalApp::implementation
}
});
}
}

View File

@@ -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.

View File

@@ -21,7 +21,8 @@
</Grid.RowDefinitions>
<local:TabRowControl x:Name="TabRow"
Grid.Row="0" />
Grid.Row="0"
KeyUp="_KeyDownHandler" />
<StackPanel Grid.Row="1">
<mux:InfoBar x:Name="KeyboardServiceWarningInfoBar"