Skip to content

Add winit phase to MouseWheel event #20438

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

liamaharon
Copy link
Contributor

@liamaharon liamaharon commented Aug 6, 2025

Objective

Allow detecting whether MouseWheel events originate from a mouse scroll wheel or trackpad.

See johanhelsing/bevy_pancam#81 (comment) for use case.

Solution

Propagate the TouchPhase from winit, which allows distinguishing mouse wheel scroll from touchpad scroll: rust-windowing/winit#4315 (comment)

Testing

I'm currently only able to test on a MacOS, it would be great if I could get help testing with a mouse and also a Windows & Linux trackpad.

Copy link
Contributor

@kristoff3r kristoff3r left a comment

Choose a reason for hiding this comment

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

This seems like a good addition. The change is very simple and I ran it on Linux and scrolling still works. If you have a small standalone example to test whether you can actually distinguish touch and scroll then I can run it on linux+web.

@@ -127,11 +127,14 @@ pub enum ForceTouch {
reflect(Serialize, Deserialize)
)]
pub enum TouchPhase {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing that feels weird to me is using the TouchPhase from touch.rs in mouse.rs. Open to suggestions if this is a concern.

@liamaharon liamaharon marked this pull request as draft August 7, 2025 02:06
@liamaharon
Copy link
Contributor Author

liamaharon commented Aug 7, 2025

Converting this to a draft - I was finally able to test with a physical mouse, and its wheel scroll events sadly also emit touch phase Moved events on my Mac. So I am not sure how useful they are. I have followed up in the winit issue.

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.

3 participants