diff options
Diffstat (limited to 'widget/src/toggler.rs')
-rw-r--r-- | widget/src/toggler.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index b1ba65c9..8b51f2d0 100644 --- a/widget/src/toggler.rs +++ b/widget/src/toggler.rs @@ -7,8 +7,8 @@ use crate::core::renderer; use crate::core::text; use crate::core::widget::Tree; use crate::core::{ - Alignment, Clipboard, Element, Event, Layout, Length, Pixels, Point, - Rectangle, Shell, Widget, + Alignment, Clipboard, Element, Event, Layout, Length, Pixels, Rectangle, + Shell, Widget, }; use crate::{Row, Text}; @@ -202,14 +202,14 @@ where _state: &mut Tree, event: Event, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, ) -> event::Status { match event { Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => { - let mouse_over = layout.bounds().contains(cursor_position); + let mouse_over = cursor.is_over(layout.bounds()); if mouse_over { shell.publish((self.on_toggle)(!self.is_toggled)); @@ -227,11 +227,11 @@ where &self, _state: &Tree, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> mouse::Interaction { - if layout.bounds().contains(cursor_position) { + if cursor.is_over(layout.bounds()) { mouse::Interaction::Pointer } else { mouse::Interaction::default() @@ -245,7 +245,7 @@ where theme: &Renderer::Theme, style: &renderer::Style, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, _viewport: &Rectangle, ) { /// Makes sure that the border radius of the toggler looks good at every size. @@ -278,7 +278,7 @@ where let toggler_layout = children.next().unwrap(); let bounds = toggler_layout.bounds(); - let is_mouse_over = bounds.contains(cursor_position); + let is_mouse_over = cursor.is_over(layout.bounds()); let style = if is_mouse_over { theme.hovered(&self.style, self.is_toggled) |