diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index a06ee98bbf..a36f322066 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -816,6 +816,18 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_ bool MainFrame::handle_global_shortcut(const KeyChord& chord) { + // ImGui draws its text fields (the text tool's box, a sketch value field) on the GL canvas, so + // while one of them is typed into the focused wx window is that canvas or an in-canvas frame: + // neither is a wxControl, so focus_keeps_space() cannot see it and CHAR_HOOK takes the chord + // here first -- Space opened the Speed Dial, Ctrl+P the Preferences, and the field never saw + // the key. ImGui raises WantCaptureKeyboard while one of its items owns the keyboard, so leave + // the key to it then. A focused wxControl (text field, list, web view) is untouched: those + // keep their own keys, and ImGui's flag can outlive the focus moving to one of them. + wxWindow* const focus = wxWindow::FindFocus(); + ImGuiWrapper* const imgui = wxGetApp().imgui(); + if (focus != nullptr && imgui != nullptr && imgui->want_keyboard() && dynamic_cast(focus) == nullptr) + return false; + const std::optional shortcut = wxGetApp().shortcuts().lookup(ShortcutContext::Global, chord); if (!shortcut.has_value()) return false;