From 0334c9549c67ed450712e22b8f7b373486c0cf2b Mon Sep 17 00:00:00 2001 From: James Pack Date: Sat, 15 Apr 2023 19:30:42 -0400 Subject: [PATCH 1/2] Default to XamlRoot when unable to find focused object in OnDirectKeyEvent --- src/cascadia/TerminalApp/TerminalWindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cascadia/TerminalApp/TerminalWindow.cpp b/src/cascadia/TerminalApp/TerminalWindow.cpp index f8a906b55a6..409b1fcea72 100644 --- a/src/cascadia/TerminalApp/TerminalWindow.cpp +++ b/src/cascadia/TerminalApp/TerminalWindow.cpp @@ -900,6 +900,12 @@ namespace winrt::TerminalApp::implementation if (!focusedObject) { focusedObject = winrt::Windows::UI::Xaml::Media::VisualTreeHelper::GetParent(focusedElement); + + // We were unable to find a focused object. Default to the xaml root so that the alt+space menu still works. + if (!focusedObject) + { + focusedObject = _root.try_as(); + } } } else @@ -908,6 +914,7 @@ namespace winrt::TerminalApp::implementation } } while (focusedObject); } + return false; } From 74a768270a1a4481dabadd4d171cf25af4ecda5f Mon Sep 17 00:00:00 2001 From: James Pack Date: Sat, 15 Apr 2023 20:14:58 -0400 Subject: [PATCH 2/2] run code format --- src/cascadia/TerminalApp/TerminalWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalApp/TerminalWindow.cpp b/src/cascadia/TerminalApp/TerminalWindow.cpp index 409b1fcea72..39fa6d1b58e 100644 --- a/src/cascadia/TerminalApp/TerminalWindow.cpp +++ b/src/cascadia/TerminalApp/TerminalWindow.cpp @@ -914,7 +914,7 @@ namespace winrt::TerminalApp::implementation } } while (focusedObject); } - + return false; }