From 3f968b8c876b7c2351232856887fb9c3e3db3130 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 12 Nov 2020 00:09:52 +0100 Subject: Make `Widget::on_event` return an `event::Status` --- native/src/widget/checkbox.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index e389427e..16a6a648 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -1,10 +1,14 @@ //! Show toggle controls using checkboxes. use std::hash::Hash; +use crate::event::{self, Event}; +use crate::layout; +use crate::mouse; +use crate::row; +use crate::text; use crate::{ - layout, mouse, row, text, Align, Clipboard, Element, Event, Hasher, - HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, - VerticalAlignment, Widget, + Align, Clipboard, Element, Hasher, HorizontalAlignment, Layout, Length, + Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; /// A box that can be checked. @@ -161,7 +165,7 @@ where messages: &mut Vec, _renderer: &Renderer, _clipboard: Option<&dyn Clipboard>, - ) { + ) -> event::Status { match event { Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => { let mouse_over = layout.bounds().contains(cursor_position); @@ -172,6 +176,8 @@ where } _ => {} } + + event::Status::Ignored } fn draw( -- cgit From 04468a7147c38cd363cb545de0d9a9881ce071dd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 12 Nov 2020 00:20:09 +0100 Subject: Implement event capturing for `Checkbox` --- native/src/widget/checkbox.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 16a6a648..42e52aef 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -172,6 +172,8 @@ where if mouse_over { messages.push((self.on_toggle)(!self.is_checked)); + + return event::Status::Captured; } } _ => {} -- cgit