-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Feature request: Add a way to determine if anything is visible (See comment) #213
Comments
if i understand your question correctly this is already implemented in form of |
Yes this will work and probably what you want. It tells you essentially if you are hovering an ImGui window (it is a little more stateful than this internally. For example: if you click outside a window and hold-drag over an window it consider that the mouse is owned by your application and doesn't request capture until the button is released). Let me know if you actually need to know about the window visibility. |
While I definitely see a good use for WantMouseCapture, there is still an issue for me that simply moving the mouse cursor to get it over an imgui window (to get WantMouseCapture to true) is going to cause the camera (normally controlled by mouse input) to orient as I move until I am over UI. Yes, this is something I could control by doing things like 'hold down CTRL to [not] move the camera", but what is best is if I could just check to see if there is any UI windows up, and if so, mouse control doesn't go to camera. |
It looks it should be part of your application code to track that then, but counting the number of draw lists will be enough of a workaround since you'll only get 1 for the mouse. I can add a call or a value to retrieve the number of active windows, you can use that but you'll have the same result as comparing the number of draw lists with >= 1.
I don't really now how to express that from the library point of view. The distinction is arbitrary so it's probably easier if you keep track of them. Say you have two counters, increment one each time you begin a window that you aim to be interactive and require mouse, and increment another for non-interactive windows, etc. |
I added a window counter. If you want to differentiate certain windows you'd have to count them yourself (you can count the "non-interactive windows" and subtract that from the total counter). Hope it helps! |
This may be a very specialized request, so I can understand if you don't want to implement it (I maintain a small change for the feature locally). But at the same time, I can see this useful for some others. If there is a way to do it with existing API, please let me know.
In our engine I decide if mouse input should go to imgui or to move the camera, depending if there is any visible UI*. Since I need to use a software mouse cursor in many situations, something is always visible (the cursor), so I can't just make this determination in the render function (there is always something to draw, so something is visible). What I did is add a bool to the ImDrawList struct that is something like "is_mouse_cursor" which is initialized to false, but set to true for the draw list of the mouse cursor.
With that information I am able to see if there is non-mouse draw lists in the render function. With that I can then make a determination if mouse movement should be fed to imgui, or sent to the camera.
*There is a situation that I'd like to handle that I haven't thought of a quick solution for, which is if a user wants to display a non-interactable window (for informational display) -- no need for a mouse cursor, so mouse input could go to the camera.
The text was updated successfully, but these errors were encountered: