Skip to content

Add is_scrolling/is_smooth_scrolling util, checking for active scroll action.#7669

Merged
IsseW merged 6 commits intomainfrom
isse/is-scrolling-util
Oct 27, 2025
Merged

Add is_scrolling/is_smooth_scrolling util, checking for active scroll action.#7669
IsseW merged 6 commits intomainfrom
isse/is-scrolling-util

Conversation

@IsseW
Copy link
Copy Markdown
Collaborator

@IsseW IsseW commented Oct 27, 2025

On native this uses a new "touch phase" parameter of the mouse wheel event to know if a scroll action is done.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 27, 2025

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

View snapshot changes at kitdiff

@IsseW IsseW added egui-winit porblems related to winit egui labels Oct 27, 2025
@IsseW IsseW marked this pull request as ready for review October 27, 2025 09:50
Copy link
Copy Markdown
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.

Nice - thank you!

A future improvement here would be to store the modifiers at TouchPhase::Start and use that when interpreting scroll events (categorizing them as zoom, or horizontal scrolling, etc). That would solve a problem we currently have where letting go of the modifier key before the last momentum-scroll events arrive will cause the scroll direction to change. This problem can be seen by going to egui.rs and opening the "Scene" example. Hold down shift, start a momentum-scroll (on a Mac trackpad), then quickly let go of shift: you'll see the scroll direction change, which feels wrong.

IsseW and others added 2 commits October 27, 2025 11:15
Co-authored-by: Emil Ernerfeldt <[email protected]>
- is_scrolling -> is_raw_scrolling and moved functions around.
- put is_in_scroll_action in an option, which is only some if we have recieved touch phase start.
- Document what to set mouse wheel touch action to on unsupported platforms
@IsseW
Copy link
Copy Markdown
Collaborator Author

IsseW commented Oct 27, 2025

A future improvement here would be to store the modifiers at TouchPhase::Start and use that when interpreting scroll events (categorizing them as zoom, or horizontal scrolling, etc). That would solve a problem we currently have where letting go of the modifier key before the last momentum-scroll events arrive will cause the scroll direction to change. This problem can be seen by going to egui.rs and opening the "Scene" example. Hold down shift, start a momentum-scroll (on a Mac trackpad), then quickly let go of shift: you'll see the scroll direction change, which feels wrong.

Oh yeah 100%

@IsseW IsseW merged commit 999e943 into main Oct 27, 2025
47 checks passed
@IsseW IsseW deleted the isse/is-scrolling-util branch October 27, 2025 10:46
@emilk
Copy link
Copy Markdown
Owner

emilk commented Oct 31, 2025

Doing some follow-ups in #7678

emilk added a commit that referenced this pull request Nov 3, 2025
### Problem
Letting go of the modifier key before the last momentum-scroll events
arrive will cause the scroll direction to change. This problem can be
seen by going to egui.rs and opening the "Scene" example. Hold down
shift, start a momentum-scroll (on a Mac trackpad), then quickly let go
of shift: you'll see the scroll direction change, which feels wrong.

### Solution
Store the modifiers at the start of the event, thanks to the new `phase`
info added in
* #7669

Note that this solution only works on native; not on web.

### Other
* Break out wheel/scroll handling into own file
* Simplify it a lot by deciding late on wether an input is a scroll or a
zoom
* Assume input is already smooth if there are `phase` events
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
…roll action. (emilk#7669)

* Closes emilk#7657
* [x] I have followed the instructions in the PR template

On native this uses a new "touch phase" parameter of the mouse wheel
event to know if a scroll action is done.

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
Letting go of the modifier key before the last momentum-scroll events
arrive will cause the scroll direction to change. This problem can be
seen by going to egui.rs and opening the "Scene" example. Hold down
shift, start a momentum-scroll (on a Mac trackpad), then quickly let go
of shift: you'll see the scroll direction change, which feels wrong.

Store the modifiers at the start of the event, thanks to the new `phase`
info added in
* emilk#7669

Note that this solution only works on native; not on web.

* Break out wheel/scroll handling into own file
* Simplify it a lot by deciding late on wether an input is a scroll or a
zoom
* Assume input is already smooth if there are `phase` events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

egui egui-winit porblems related to winit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flicking with a trackpad has empty deltas inbetween non-zero deltas

2 participants