Skip to content
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

ImGui::IsMouseHoveringAnyWindow() frame mismatch #635

Closed
josiahmanson opened this issue May 6, 2016 · 4 comments
Closed

ImGui::IsMouseHoveringAnyWindow() frame mismatch #635

josiahmanson opened this issue May 6, 2016 · 4 comments

Comments

@josiahmanson
Copy link
Contributor

I am testing out adding ImGui to an existing program. In that program, dragging the mouse with a button pressed rotates the view. I am trying to restrict my event processing to only happen when the mouse is not over an ImGui windows. To do so, I tried using the handy function ImGui::IsMouseHoveringAnyWindow(). This mostly works, but if I drag a window near the edge quickly, the function returns false and rotates my view. There appears to be a mismatch between the mouse position that IsMouseHoveringAnyWindow() checks and the actual window position. In this case, it appears that the window position is behind. This could be solved by storing the mouse position during the previous frame and checking against that in IsMouseHoveringAnyWindow().

@ocornut
Copy link
Owner

ocornut commented May 6, 2016

You should be using io.WantCaptureMouse here. Have you read the documentation in the header of imgui.cpp ? IsMouseHoveringAnyWindow isn't what you want as it won't handle many dragging cases. Going to add the io.WantCaptureXXX flags in the FAQ right now.

However from the point of view IsMouseHoveringAnyWindow there is a minor bug here from the point of view of the user. The bug is caused because moving a window is processed the first time Begin() is called for that window during the frame. The fix should probably be to copy HoveredWindow = MovedWindow when the later isn't NULL. Looking into it.

ocornut added a commit that referenced this issue May 6, 2016
@ocornut
Copy link
Owner

ocornut commented May 6, 2016

This is due to a bug in FindHoveredWindow() which is subject to a lag introduced when I added the WindowRectClipped field (just renamed from ClippedWindowRect which was mislabelled and misdocumented). WindowRectClipped is set based on window Pos/Size in Begin(), so after FindHoveredWindow() is called. The lag has minor side-effects. I have documented it for now and fixed it in the case of MovingWindow, also reorganized the MovingWindow code.

Repro

ImGui::Begin("Bug #635");
ImGui::Text("%d", ImGui::IsMouseHoveringAnyWindow());
ImGui::End();

@ocornut ocornut closed this as completed May 6, 2016
@ocornut
Copy link
Owner

ocornut commented Sep 27, 2017

Reopening as commit 313d388 caused an issue (#1337).
Also note that IsPosHoveringAnyWindow was completely removed, as it was both misleading and buggy, so we can reassert what to do considering that.

@ocornut ocornut reopened this Sep 27, 2017
@ocornut
Copy link
Owner

ocornut commented Sep 27, 2017

Fixed the bug introduced by this change.
The specific bug initially reported here is also still fixed.S
So closing again :)

@ocornut ocornut closed this as completed Sep 27, 2017
ocornut added a commit that referenced this issue Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants