Skip to content
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

Update scrollable children with new cursor position while scrolling #2439

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,45 @@ where
content_bounds,
shell,
) {
// We've changed the viewport but the child widget still thinks that the mouse is in the same relative place.
if let (Some(cursor_position), Some(cursor_position_abs)) =
(cursor_over_scrollable, cursor.position())
{
if !(mouse_over_x_scrollbar || mouse_over_y_scrollbar) {
let cursor = mouse::Cursor::Available(
cursor_position
+ state.translation(
self.direction,
bounds,
content_bounds,
),
);

let translation = state.translation(
self.direction,
bounds,
content_bounds,
);

_ = self.content.as_widget_mut().on_event(
&mut tree.children[0],
Event::Mouse(mouse::Event::CursorMoved {
position: cursor_position_abs,
}),
content,
cursor,
renderer,
clipboard,
shell,
&Rectangle {
y: bounds.y + translation.y,
x: bounds.x + translation.x,
..bounds
},
);
}
};

event::Status::Captured
} else {
event::Status::Ignored
Expand Down
Loading