-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 raw mouse wheel event #2782
Conversation
The event is sent as it comes from the backend, so it will follow different conventions depending on the target, and it is up to the user code to deal with that. The goal is to allow advanced users to implement alternative UI controls, e.g., using Ctrl to scroll the plot horizontally instead of zooming, or use Shift to scroll faster instead of changing direction.
This implementation provides maximum information and flexibility to the user of egui, but it also gives them the burden of having to know the specifics of the backend/target they're building for. For example, in winit, scrolling down one step produces a delta of (0.0, -1.0) lines, whereas in web the delta is (0.0, 6.0) lines. Also, the x and y coordinates are swapped when holding down shift on macOS (both winit and web), but not on other targets. An alternative would be to create a universal convention, similar to how the But this convention would end up being very similar to the |
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.
Good idea, but let's use the same unit (points) for both web and native
Apply suggestions from code review by emilk Co-authored-by: Emil Ernerfeldt <[email protected]>
e994fa4
to
fb08a4c
Compare
It was meant only to be able to use the same variable names without shadowing the rest of the code, but a simple block accomplishes the same thing.
fb08a4c
to
3d1655d
Compare
Co-authored-by: Emil Ernerfeldt <[email protected]>
To avoid doing the same match and sign conversion twice.
This is great; thank you! |
* Add raw mouse wheel event The event is sent as it comes from the backend, so it will follow different conventions depending on the target, and it is up to the user code to deal with that. The goal is to allow advanced users to implement alternative UI controls, e.g., using Ctrl to scroll the plot horizontally instead of zooming, or use Shift to scroll faster instead of changing direction. * Change Pixel to Point for consistency Apply suggestions from code review by emilk Co-authored-by: Emil Ernerfeldt <[email protected]> * Inline mouse wheel raw event closure It was meant only to be able to use the same variable names without shadowing the rest of the code, but a simple block accomplishes the same thing. * Use wildcard on wheel event match Co-authored-by: Emil Ernerfeldt <[email protected]> * Flip mouse wheel delta sign on web to match native * Use wheel event data to generate scroll event To avoid doing the same match and sign conversion twice. --------- Co-authored-by: Emil Ernerfeldt <[email protected]>
The event is sent as it comes from the backend, so it will follow different conventions depending on the target, and it is up to the user code to deal with that. The goal is to allow advanced users to implement alternative UI controls, e.g., using Ctrl to scroll the plot horizontally instead of zooming, or use Shift to scroll faster instead of changing direction.
Closes #2718.