From 9b91eff8c4cde57339e00b00fd2c50bda110c4cb Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Sun, 12 Sep 2021 12:00:03 +0100 Subject: [PATCH] Don't forward keys when imgui has focus. This prevents typing in boxes trigging key events for imgui. It's not a perfect fix, because you still need the release event to propgate (ie, when holding down a key then selecting an imgui text box). But it'll do without tight imgui/fggl integration. --- vendor/imgui/backends/imgui_impl_glfw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/imgui/backends/imgui_impl_glfw.cpp b/vendor/imgui/backends/imgui_impl_glfw.cpp index 971686b..8686258 100644 --- a/vendor/imgui/backends/imgui_impl_glfw.cpp +++ b/vendor/imgui/backends/imgui_impl_glfw.cpp @@ -109,10 +109,10 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yo void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (g_PrevUserCallbackKey != NULL) + ImGuiIO& io = ImGui::GetIO(); + if (g_PrevUserCallbackKey != NULL && !io.WantCaptureKeyboard) g_PrevUserCallbackKey(window, key, scancode, action, mods); - ImGuiIO& io = ImGui::GetIO(); if (key >= 0 && key < IM_ARRAYSIZE(io.KeysDown)) { if (action == GLFW_PRESS) -- GitLab