Skip to content

Commit

Permalink
Do not capture released event inside image::Viewer when mouse is no…
Browse files Browse the repository at this point in the history
…t dragged
  • Loading branch information
rhysd committed Jan 23, 2025
1 parent 75a6f32 commit c186ca1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions widget/src/image/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,20 @@ where
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => {
let state = tree.state.downcast_mut::<State>();

if state.cursor_grabbed_at.is_some() {
if let Some(grab_start) = state.cursor_grabbed_at {
state.cursor_grabbed_at = None;
shell.capture_event();

let dragged = cursor
.position_over(bounds)
.map(|grab_end| {
(grab_start.x - grab_end.x).abs() >= 1.0
|| (grab_start.y - grab_end.y).abs() >= 1.0
})
.unwrap_or(true);

if dragged {
shell.capture_event();
}
}
}
Event::Mouse(mouse::Event::CursorMoved { position }) => {
Expand Down

0 comments on commit c186ca1

Please sign in to comment.