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

Correctly handle releasing mouse buttons when not hovering a window #121

Closed

Conversation

TheRawMeatball
Copy link
Contributor

No description provided.

Comment on lines +131 to +132
if let Some(window_id) = &cursor_left_window {
if cursor_left_window != cursor_entered_window {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for the PR.

Is the goal here to fix the behaviour for any platform? I believe this branch will be entered only for Safari, as this is the only browser that emits CursorLeft and CursorEntered on mouse button release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems off since this change fixed unexpected behavior on desktop linux.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Furthermore, this branch needs to be possible to entered on all platforms - after all it's the only branch where mouse_position is reset.

Copy link
Owner

@mvlabat mvlabat Sep 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. I'm not sure it's working as intended. If I keep dragging the mouse pointer and it leaves the window, it'll fire the release button event immediately (as demonstrated in the video). Yet in the main version we keep reading mouse events when outside of a window, which allows us to continue dragging sliders for example (see #61).

Screen.Recording.2022-09-17.at.11.50.24.mov

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not sure I understand what issue the PR is trying to address (or whether the issue indeed exists).

During this recording (the main branch), I dragged the cursor outside of the window, released it when being outside, moved the cursor back to the window, and we can see that bevy_egui didn't continue drawing to the canvas. If I understand correctly, your point is that we don't fire mouse release events when releasing the cursor outside of the window. But if that was the case, wouldn't it keep drawing when I moved the cursor back to the window?

Screen.Recording.2022-09-17.at.11.56.30.mov

Copy link
Contributor Author

@TheRawMeatball TheRawMeatball Sep 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I just tested the main branch - the drawing continues when i release the button outside the window and move the cursor back in. Perhaps the issue doesn't happen on macs for one reason or another?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

egui-show-bug-.webm

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, thanks for clarifying. I was indeed able to reproduce it on my KDE laptop.

Turns out, for some platforms, winit fires CursorLeft together with button input events when releasing a button outside of a window. I've just pushed #123 with the fix that also preserves the dragging behaviour. Could you please test it and let me know if it works for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged and released. Thanks again for flagging it!

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

Successfully merging this pull request may close these issues.

None yet

2 participants