-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add logic for CursorEntered/CursorLeft on Windows #150
Add logic for CursorEntered/CursorLeft on Windows #150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be implemented without any additional state tracking or heuristics.
Take a look at the documentation of TrackMouseEvent
. You can use it to get WM_MOUSEHOVER
events when the cursor enters the client area, and WM_MOUSELEAVE
events when the cursor leaves the client area. You need to set both the TME_HOVER
and the TME_LEAVE
flags in the TRACKMOUSEEVENT
struct for that to work, and you need to repeat the call any time you receiver either of the two window messages. So the idea is that you call it after creating the window, and you then repeat the exact same call when handling those two window messages.
I first tried to do it like that, but edit: also looks like winit does it the same way as I: https://github.com/rust-windowing/winit/blob/ee0db52ac49d64b46c500ef31d7f5f5107ce871a/src/platform_impl/windows/event_loop.rs#L1443 |
In that case you'd be able to just only set |
For some reason there is no |
Sorry yeah I meant |
Ah okay. For reasons I don't really understand just sending I digged up the documentation I based this on. |
94d21af
to
b46a6ad
Compare
b46a6ad
to
d8cedc8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to feel about the Win32 API for this, but I guess this is the way to do it. 😅
LGTM.
Necessary to fix vizia/vizia#407, which is a bug that locks up the GUI when you press down on a mouse button inside the window and release the button outside the window.