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
Fix scroll_with_delta only scrolling if the ScrollArea is focussed #4303
base: master
Are you sure you want to change the base?
Conversation
366e756
to
46d2303
Compare
crates/egui/src/ui.rs
Outdated
input.smooth_scroll_delta += delta; | ||
input.force_current_scroll_area = true; |
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.
I think a better fix is to add a scroll_delta
to FrameState
, alongside FrameState::scroll_target
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.
That is indeed much nicer 👍 I've updated my PR
74d74f9
to
5c4c191
Compare
crates/egui/src/frame_state.rs
Outdated
pub(crate) scroll_target: [Option<(Rangef, Option<Align>)>; 2], | ||
|
||
/// The current scroll area should scroll by this much (horizontal, vertical). | ||
pub(crate) scroll_delta: [Option<f32>; 2], |
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.
This could just be a Vec2
, no?
pub(crate) scroll_delta: [Option<f32>; 2], | |
pub(crate) scroll_delta: Vec2, |
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.
Updated. I think we could also update scroll_target to be Option<[(..); 2]>
instead of [Option<(..)>; 2]
. That would make the code in Prepared::end a bit cleaner. I don't think a single direction is ever read / set alone, it's always both directions at once. Should I include that change as well?
This introduces the boolean field force_current_scroll_area to InputState which will be set when scroll_with_delta is called, causing the ScrollArea to skip the check whether it is focused and always consume the smooth scroll delta.
scroll_with_delta
doesn't work #2783