Skip to content

Conversation

@thatcomputerguy0101
Copy link
Contributor

This adds support to receive rotation gesture information from sources that don't provide touch events, such as trackpads on MacOS. Currently, only the winit backend passes through the necessary information. I would also like to add support for the web backend on Safari, as that generates a GestureEvent (MDN, WebKit JS) with rotation information. However, since that is a non-standard API, it is not yet exposed in web-sys.

@thatcomputerguy0101
Copy link
Contributor Author

GestureEvent support in web-sys: wasm-bindgen/wasm-bindgen#4589
Alternatively, js_sys::Reflect could be used to dynamically extract the fields.

@thatcomputerguy0101
Copy link
Contributor Author

I implemented GestureEvent support utilizing js_sys::Reflect since it is a non-standard API. With that, both of eframe's backends now support rotation input in this PR.

@thatcomputerguy0101 thatcomputerguy0101 marked this pull request as ready for review August 21, 2025 18:14
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Thanks!

Code LGTM, but we should have some way of testing this in egui_demo_app. We have the Multi Touch demo, but that doesn't work with this PR.

@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Preview available at https://egui-pr-preview.github.io/pr/7453-rotationgesture
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@thatcomputerguy0101
Copy link
Contributor Author

The Multi Touch demo could respond to smooth_scroll_delta, zoom_delta, and rotation_delta. However, all three of those will yield input at the same time as multi_touch, which would make the existing processing redundant. Also, the current touches label might be confusing if it is left as reporting zero touches (since no multi_touch exists) while the state is changing.

@emilk
Copy link
Owner

emilk commented Sep 4, 2025

We could rename Multi Touch to something else, like Trackpad and Multitouch and then adapt its UI accordingly 🤔

@thatcomputerguy0101
Copy link
Contributor Author

Keeping it called Multi Touch isn't entirely inaccurate. The relevant events are still produced by the same physical actions, just on a trackpad instead of a touch screen. The current touches label could be swapped out to say Input source: none, Input source: 2-finger touch, or Input source: cursor depending on the incoming events.

I have also been working on some changes in winit to support multitouch trackpad gestures on Wayland, which will generate PinchGesture, RotateGesture, and PanGesture. Notably, PanGesture is the same physical action as MouseWheel. Which one is sent depends on if scrolling is detected first or if pinch/rotation is detected first . Therefore, a PanGesture from winit should probably be mapped to scrolling input in egui.

@emilk emilk added web Related to running Egui on the web eframe Relates to epi and eframe egui-winit porblems related to winit egui labels Sep 7, 2025
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Very nice - works great with my trackpad!

@emilk emilk merged commit b0c568a into emilk:main Sep 11, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eframe Relates to epi and eframe egui egui-winit porblems related to winit web Related to running Egui on the web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants