-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mouse and keyboard events at the same time #5888
Comments
Hello, I can confirm there is "kind of" a bug related to the key ownership system, specifically when CLICKING on a window to move it, as the moving-window operation is preventing keys from having other actions (not specifically mods key but any keys). Simpler repro: const bool isCtrlDown = ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl);
const bool isLeftPressed = ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsMouseDragging(ImGuiMouseButton_Left);
ImGui::Text("isCtrlDown = %s, isLeftPressed = %s", isCtrlDown ? "Ctrl" : "----", isLeftPressed ? "Left" : "----"); Also note that you are likely to want to use the Mod and not keys: const bool isCtrlDown = ImGui::IsKeyDown(ImGuiMod_Ctrl);
const bool isLeftPressed = ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsMouseDragging(ImGuiMouseButton_Left);
ImGui::Text("isCtrlDown = %s, isLeftPressed = %s", isCtrlDown ? "Ctrl" : "----", isLeftPressed ? "Left" : "----"); (same issue will appear here but this is simpler) However note that it doesn't seem regular/wise to react while simultaneously moving a window which is what you are doing here.
Why? Can you explain the context? Right now if you use
|
Pushed d60985d Amend change of Note that your code polling I'll keep this open because I would like to investigate |
I've pushed another fix 7bee9a8 to make the behavior more consistent with pre-4448d97 logic. |
Wow that was fast! I tried with your fixes and it's working :) My intention is to use the mouse and keyboard to provide navigation in a 3D viewport. Like, for example, rotation with mouse left click and translation with left + Ctrl. For that, I also made it so each window can only be moved using the tittle bar. Thanks again @ocornut ! |
Then you should indeed use InvisibleButton() to grab inputs at that location. |
What is the difference of using an InvisibleButton? Not sure how to use it, do you have any link I could look at? Thanks. |
Then call |
It worked! Thanks @ocornut :) |
…cornut#5888, ocornut#4921, ocornut#456) Amend change of SetActiveIdUsingAllKeyboardKeys() in 4448d97 which seemingly accidentally reverted the change intended by fd408c9
…put-owner-unaware code from accessing keys. (ocornut#5888, ocornut#4921, ocornut#456) Amend 4448d97. This is more consistent with input owner design.
Version/Branch of Dear ImGui:
Version: 1.89
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
Compiler: MSC_VER=1933
Operating System: Windows 10
My Issue/Question:
Hey, I'm trying to obtain mouse and keyboard events when the mouse is hovering a specific window. More specifically, I'm trying to check if both the left mouse button and the ctrl key are down/pressed. However, I'm only getting events from one of them at the same time, even when both are pressed. If I remember well, having both at the same time was possible before so I'm wondering if something changed with the recent version 1.89 that I'm missing. Here is some example code in case it helps:
Thanks in advance!
The text was updated successfully, but these errors were encountered: