From c7f6b2a5c7778cdbd39e327bfac196014140902c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 11 Jan 2021 19:31:34 +0100 Subject: [PATCH] Capture relevant events in `image::Viewer` --- native/src/widget/image/viewer.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/native/src/widget/image/viewer.rs b/native/src/widget/image/viewer.rs index 4ec3faf6..5f0dda4e 100644 --- a/native/src/widget/image/viewer.rs +++ b/native/src/widget/image/viewer.rs @@ -209,15 +209,23 @@ where } } } + + event::Status::Captured } Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) if is_mouse_over => { self.state.cursor_grabbed_at = Some(cursor_position); self.state.starting_offset = self.state.current_offset; + + event::Status::Captured } - Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => { - self.state.cursor_grabbed_at = None + Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) + if self.state.cursor_grabbed_at.is_some() => + { + self.state.cursor_grabbed_at = None; + + event::Status::Captured } Event::Mouse(mouse::Event::CursorMoved { position }) => { if let Some(origin) = self.state.cursor_grabbed_at { @@ -251,12 +259,14 @@ where }; self.state.current_offset = Vector::new(x, y); + + event::Status::Captured + } else { + event::Status::Ignored } } - _ => {} + _ => event::Status::Ignored, } - - event::Status::Ignored } fn draw(