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

Fix scrollbars when pointer capture is released #858

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions masonry/src/widgets/scroll_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Widget for ScrollBar {
}
ctx.request_render();
}
PointerEvent::PointerUp(_, _) => {
PointerEvent::PointerUp(_, _) | PointerEvent::PointerLeave(_) => {
self.grab_anchor = None;
ctx.request_render();
}
Comment on lines -157 to 160
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point I wonder if we should add an Update::PointerCaptureChanged event.

Expand Down Expand Up @@ -233,7 +233,7 @@ mod tests {

use super::*;
use crate::assert_render_snapshot;
use crate::core::PointerButton;
use crate::core::{PointerButton, PointerState};
use crate::testing::{widget_ids, TestHarness, TestWidgetExt};

#[test]
Expand Down Expand Up @@ -261,6 +261,12 @@ mod tests {

harness.mouse_move(Point::new(30.0, 300.0));
assert_render_snapshot!(harness, "scrollbar_bottom");

harness.process_pointer_event(PointerEvent::PointerLeave(PointerState::empty()));
// Move the mouse to a place where if the scrollbar was still grabbing, it would move the scrollbar
harness.mouse_move(Point::new(30.0, 100.0));
// We can reuse the same snapshot, because scrollbars don't currently indicate they are pressed
assert_render_snapshot!(harness, "scrollbar_bottom");
}

#[test]
Expand Down