From 5be80a9cc631303a644d14654a1d01603df138b1 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 14 Mar 2026 04:36:25 -0700 Subject: [PATCH] fix(chat): suppress hotkeys while UI captures keyboard --- src/ui/game_screen.cpp | 2 +- src/ui/keybinding_manager.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 6c4f8f52..f9108e1a 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -2288,7 +2288,7 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) { refocusChatInput = true; } - const bool textFocus = chatInputActive || refocusChatInput || io.WantTextInput; + const bool textFocus = chatInputActive || refocusChatInput || io.WantTextInput || io.WantCaptureKeyboard; // Tab targeting (when keyboard not captured by UI) if (!io.WantCaptureKeyboard) { diff --git a/src/ui/keybinding_manager.cpp b/src/ui/keybinding_manager.cpp index a96a040e..ca2a6cd5 100644 --- a/src/ui/keybinding_manager.cpp +++ b/src/ui/keybinding_manager.cpp @@ -47,7 +47,9 @@ bool KeybindingManager::isActionPressed(Action action, bool repeat) { // When typing in a text field (e.g. chat input), never treat A-Z or 0-9 as shortcuts. const ImGuiIO& io = ImGui::GetIO(); - if (io.WantTextInput) { + // Note: WantTextInput may not be set until the text widget is processed later in the + // frame, but WantCaptureKeyboard remains true while an ImGui widget is active. + if (io.WantTextInput || io.WantCaptureKeyboard) { if ((key >= ImGuiKey_A && key <= ImGuiKey_Z) || (key >= ImGuiKey_0 && key <= ImGuiKey_9)) { return false;