ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.51k stars 10.14k forks source link

io.WantCaptureMouse doesn't work for scrollwheel #7588

Open YTN0 opened 4 months ago

YTN0 commented 4 months ago

Version/Branch of Dear ImGui:

Latest

Back-ends:

Custom

Compiler, OS:

Windows 11

Full config/build information:

No response

Details:

io.WantCaptureMouse always seems to return true for scrollwheel changes even when not "captured" within a window. This makes it difficult to tell if a scrollwheel action is intended for the window or the main (non-ImGui) UI.

Any recommended solutions for this?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

ocornut commented 4 months ago

Merely hovering a window will generally set io.WantCaptureMouse, and mouse wheels are processed by hovered windows, so I am not sure I understand your question or reasoning. Could you clarify?

YTN0 commented 4 months ago

I have some imgui windows on the screen overlaying parts of the main rendered window.

For my mouse event processing, I send the mouse events to imgui first and if WantCaptureMouse is false, I then forward the event to my main mouse event handler.

For scrollwheel events., even when I am not over an imgui window (am over the main rendered screen) and I send the mouse scroll event to imgui, it returns "true" for WantCaptureMouse., so my main window (which should process the event) never gets it.

ocornut commented 4 months ago

For scrollwheel events., even when I am not over an imgui window (am over the main rendered screen) and I send the mouse scroll event to imgui, it returns "true" for WantCaptureMouse., so my main window (which should process the event) never gets it.

That's not the case in our vanilla demo, you can verify it in Demo->Inputs. And as a general fact wheel state or events have no effect on WantCaptureMouse. So I think you have another thing interfering which is causing WantCaptureMouse to be set.

When unsure, just display the live value using ImGui::Text() so you can investigate.