From d946f65270cbdf7b4a01ca75f9756ea92609700c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 9 Nov 2026 19:08:34 +0100 Subject: [PATCH] ImDebugger: Fix the memory window stealing keys, and keys stuck after closing The memory window's single-letter shortcuts (F, B, H, U...) were taken even when it wasn't focused, opening the search form and focusing its text field while the game had the keyboard. Only take them when the window is focused, like the disassembly window does. Key events don't reach imgui while the debugger is hidden, so a key held while closing it stayed down. Clear imgui's key state while it's hidden. Co-Authored-By: Claude Opus 5.5 --- UI/ImDebugger/ImMemView.cpp | 4 +++- UI/NativeApp.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/UI/ImDebugger/ImMemView.cpp b/UI/ImDebugger/ImMemView.cpp index 2d2f2e5f4d..7acea19d12 100644 --- a/UI/ImDebugger/ImMemView.cpp +++ b/UI/ImDebugger/ImMemView.cpp @@ -1218,8 +1218,10 @@ void ImMemWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl & StatusBar(memView_.StatusMessage()); + // These are single letters, so only take them when this window has focus, or they'd be stolen from the game. + const bool focused = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); ImGui::End(); - if (!ImGui::GetIO().WantTextInput) { + if (focused && !ImGui::GetIO().WantTextInput) { ProcessKeyboardShortcuts(); } } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index d42cc72aa7..628646b54c 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -446,6 +446,8 @@ void runImDebugger(Draw::DrawContext *draw) { SetOverrideScreenFrame(nullptr); if (imDebugger_) { imDebugger_->OnHidden(); + // Key events don't reach imgui while it's hidden, so it would miss the release of a key held when it closed. + ImGui::GetIO().ClearInputKeys(); } }