
My application uses a TabbedMdiHost
, which opens a tab switcher UI via Ctrl+Tab
. One of my document types has a web browser control (a DotNetBrowser BrowserView
). The web browser embeds a Chromium window using an HwndHost, so all input ends up getting routed to that window.
I noticed that SwitcherBase.ProcessKeyDown
is called when handling a PreviewKeyDown
event, so I have my browser key event handler raising that event like so:
if (e.Modifiers.ControlDown && e.VirtualKey == KeyCode.Tab)
{
KeyEventArgs args = new(
Keyboard.PrimaryDevice,
PresentationSource.FromDependencyObject(this),
0,
key)
{
RoutedEvent = PreviewKeyDownEvent,
Source = this
};
InputManager.Current.ProcessInput(args);
}
This does successfully open the tab switcher UI, but at that point, keyboard input no longer works and the tab switcher UI is stuck open until I click somewhere. Focus does leave the browser, but I'm not sure where it is going or how to figure that out.