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

Context::wants_pointer_input() is false when dragging over a dropdown #600

Closed
obiwanus opened this issue Aug 1, 2021 · 3 comments
Closed

Comments

@obiwanus
Copy link

obiwanus commented Aug 1, 2021

I was trying to stop my engine to react to pointer events while it's over egui or is otherwise interacting with it, and Context::wants_pointer_input() seems to be exactly for this.

It works very well, however if you hover over e.g. a dropdown and press a mouse button, then suddenly this function returns false. This means that when I'm clicking a dropdown I may accidentally select an object behind the GUI.

I've reproduced the problem on the official egui_glium example and recorded a screencast to demonstrate: https://www.youtube.com/watch?v=pGcuXdO0yxc

Thanks for the great crate!

UPD. I just realised it's true not only for dropdowns but for general dragging over panels etc. as well -- presumably because the function wants to make sure that if a drag started outside UI then it won't grab the cursor, but what that means that if you start the drag while over the UI but not over an active element (e.g. a slider) then the function will erroneously assume it's outside UI.

@jsatka
Copy link

jsatka commented Jan 28, 2022

It sounds like Context::is_pointer_over_area() is what you are looking for.

@emilk
Copy link
Owner

emilk commented Feb 5, 2022

This is by design (though perhaps a bit confusing). It works like this:

If you are hovering an egui area, then wants_pointer_input = true, because egui may want to do hover effects.

If you drag an egui widget that responds to drags (e..g. a slider), then wants_pointer_input returns true, because egui needs to track the mouse. it doesn't matter where the mouse is (i.e. if it leaves an egui area).

If your mouse button is down but you are not clicking or dragging any widget, then egui assumes you are interacting with your game (or whatever).

Perhaps wants_pointer_input should return true if the drag originated in an egui area, even if there is nothing there to drag, but this requires keeping track of more state, do that's not how it currently works. As @jsatka points out: you can use Context::is_pointer_over_area to augment this for now.

@obiwanus
Copy link
Author

obiwanus commented Feb 6, 2022

Thanks, it makes sense now. I will close this issue then.

@obiwanus obiwanus closed this as completed Feb 6, 2022
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

3 participants