-
Notifications
You must be signed in to change notification settings - Fork 66
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
io.WantCaptureMouse possible bug because of the way rllmGui is implemented #49
Comments
I reproduced the same thing with SDL as the backend and I got the same problem, the io.WantCaptureMouse is updated only after you release the mouse left button. Which means that my approach of detecting this kind of overlapping while holding the button is wrong. A bit older issue related to this problem is this one: ocornut/imgui#1392 |
I'm not sure what you are talking about here. setMouseEvent looks for state changes in the mouse button and passes them as events to ImGui. IsMouseButtonPressed detects when the button goes from up to down and sends a down event to ImGui. IsMouseButtonReleased does the opposite. ImGui detects the down state by these events. You can see the state is correct in the ImGui demo window's input section. if you want to know if ImGui is using the mouse you can look at WantCaptureMouse in the io structure. When that is true, your application should ignore the mouse input because ImGui is using it. |
I was not clear enough. I am sorry. |
I think this is by design and not something that rlImGui can control. When you click outside of an ImGui element, ImGui knows that the app has focus. During the drag, the focus does not change until that focused event ends. Basically if you start a drag outside of ImGui, it stays alive even if it goes 'under' ImGui, so your drag is not interrupted. Changing capture during the drag would break the expected behavior of the drag staying in the app's context. WantCapture is only true when ImGui knows 100% that it wants the input. In the middle of a background drag, it doesn't know if it can or should take over that drag, so it can't return true there. There is no change that can be made to rlImGui that will change this behavior. If you want to break your drag when you go over an element, then I think you may need to check the hover state of your windows and set your own flag. You would then have to pick up your drag again when you leave a hover state. |
I have a simulator for point charges and I have implemented a function that allows charges to be dragged while holding mouse left button. I want to block dragging charges function under the ImGui windows.
I have succeeded to block all other functions under ImGui windows like (Add Charge, Remove Charge, Select Charge), but all these functions have in common IsMouseButtonPressed function.
For the dragging charges function I used IsMouseButtonDown and I observed that the dragging is still working under the ImGui windows, and after a bit of debugging I found out that the io.WantCaptureMouse variable is not changed If I hold the left button, and I think that these lines are the reason, because they are taking into consideration only the Pressed function, but the Down function has a different behavior.
auto setMouseEvent = [&io](int rayMouse, int imGuiMouse) { if (IsMouseButtonPressed(rayMouse)) io.AddMouseButtonEvent(imGuiMouse, true); else if (IsMouseButtonReleased(rayMouse)) io.AddMouseButtonEvent(imGuiMouse, false); };
How could I fix the problem?
Changing the approach maybe, or is there an alternative for the rllImGui Process Event function that would fix the problem?
Maybe I am missing something.
Thank you.
The text was updated successfully, but these errors were encountered: