From 4bc4730e15b560895b89e465944672f908e23b10 Mon Sep 17 00:00:00 2001 From: Marco Livesu Date: Fri, 24 Nov 2023 12:33:52 +0100 Subject: [PATCH] hack to make backspace work in ImGui --- include/cinolib/gl/glcanvas.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/cinolib/gl/glcanvas.cpp b/include/cinolib/gl/glcanvas.cpp index 25b0c8af..ccd8ce56 100644 --- a/include/cinolib/gl/glcanvas.cpp +++ b/include/cinolib/gl/glcanvas.cpp @@ -573,7 +573,18 @@ void GLcanvas::key_event(GLFWwindow *window, int key, int /*scancode*/, int acti // if visual controls claim the event, let them handle it! if(ImGui::GetIO().WantCaptureKeyboard) { - if(action==GLFW_RELEASE) ImGui::GetIO().AddInputCharacter(key); + if(action==GLFW_PRESS && key==GLFW_KEY_BACKSPACE) + { + ImGui::GetIO().AddKeyEvent(ImGuiKey_Backspace,true); + } + else if(action==GLFW_RELEASE) + { + switch(key) + { + case GLFW_KEY_BACKSPACE : ImGui::GetIO().AddKeyEvent(ImGuiKey_Backspace,false); break; + default : ImGui::GetIO().AddInputCharacter(key); + } + } return; }