diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index 1cd2faf00..fa756500b 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -138,12 +138,46 @@ void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow*, int key, int, int action, int mo { ImGuiIO& io = ImGui::GetIO(); if (action == GLFW_PRESS) - io.KeysDown[key] = true; + { + switch (key) + { + case GLFW_KEY_LEFT_CONTROL: + case GLFW_KEY_RIGHT_CONTROL: + io.KeyCtrl = true; + break; + case GLFW_KEY_LEFT_SHIFT: + case GLFW_KEY_RIGHT_SHIFT: + io.KeyShift = true; + break; + case GLFW_KEY_LEFT_ALT: + case GLFW_KEY_RIGHT_ALT: + io.KeyAlt = true; + break; + default: + io.KeysDown[key] = true; + } + } + if (action == GLFW_RELEASE) - io.KeysDown[key] = false; - io.KeyCtrl = (mods & GLFW_MOD_CONTROL) != 0; - io.KeyShift = (mods & GLFW_MOD_SHIFT) != 0; - io.KeyAlt = (mods & GLFW_MOD_ALT) != 0; + { + switch (key) + { + case GLFW_KEY_LEFT_CONTROL: + case GLFW_KEY_RIGHT_CONTROL: + io.KeyCtrl = false; + break; + case GLFW_KEY_LEFT_SHIFT: + case GLFW_KEY_RIGHT_SHIFT: + io.KeyShift = false; + break; + case GLFW_KEY_LEFT_ALT: + case GLFW_KEY_RIGHT_ALT: + io.KeyAlt = false; + break; + default: + io.KeysDown[key] = false; + } + } } void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c) diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp index 8c9cb2169..3349a2664 100644 --- a/examples/opengl_example/imgui_impl_glfw.cpp +++ b/examples/opengl_example/imgui_impl_glfw.cpp @@ -119,12 +119,46 @@ void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods) { ImGuiIO& io = ImGui::GetIO(); if (action == GLFW_PRESS) - io.KeysDown[key] = true; + { + switch (key) + { + case GLFW_KEY_LEFT_CONTROL: + case GLFW_KEY_RIGHT_CONTROL: + io.KeyCtrl = true; + break; + case GLFW_KEY_LEFT_SHIFT: + case GLFW_KEY_RIGHT_SHIFT: + io.KeyShift = true; + break; + case GLFW_KEY_LEFT_ALT: + case GLFW_KEY_RIGHT_ALT: + io.KeyAlt = true; + break; + default: + io.KeysDown[key] = true; + } + } + if (action == GLFW_RELEASE) - io.KeysDown[key] = false; - io.KeyCtrl = (mods & GLFW_MOD_CONTROL) != 0; - io.KeyShift = (mods & GLFW_MOD_SHIFT) != 0; - io.KeyAlt = (mods & GLFW_MOD_ALT) != 0; + { + switch (key) + { + case GLFW_KEY_LEFT_CONTROL: + case GLFW_KEY_RIGHT_CONTROL: + io.KeyCtrl = false; + break; + case GLFW_KEY_LEFT_SHIFT: + case GLFW_KEY_RIGHT_SHIFT: + io.KeyShift = false; + break; + case GLFW_KEY_LEFT_ALT: + case GLFW_KEY_RIGHT_ALT: + io.KeyAlt = false; + break; + default: + io.KeysDown[key] = false; + } + } } void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)