Skip to content

Improve modifier handling when scrolling#7678

Merged
emilk merged 8 commits intomainfrom
emilk/scroll-refactor
Nov 3, 2025
Merged

Improve modifier handling when scrolling#7678
emilk merged 8 commits intomainfrom
emilk/scroll-refactor

Conversation

@emilk
Copy link
Copy Markdown
Owner

@emilk emilk commented Oct 31, 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

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

@emilk emilk added the egui label Oct 31, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 31, 2025

Preview available at https://egui-pr-preview.github.io/pr/7678-emilkscroll-refactor
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

@emilk emilk changed the title Make InputState::smooth_scroll_delta into a function Improve modifier handling when scrolling Oct 31, 2025
@emilk emilk marked this pull request as ready for review October 31, 2025 13:51
@emilk emilk requested a review from IsseW October 31, 2025 13:51
Copy link
Copy Markdown
Collaborator

@IsseW IsseW left a comment

Choose a reason for hiding this comment

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

This is a good improvement!

@emilk emilk merged commit 1b77d70 into main Nov 3, 2025
47 checks passed
@emilk emilk deleted the emilk/scroll-refactor branch November 3, 2025 10:53
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants