diff options
author | 2023-06-08 20:11:59 +0200 | |
---|---|---|
committer | 2023-06-08 20:11:59 +0200 | |
commit | 34451bff185d8875f55747ee97ed746828e30f40 (patch) | |
tree | 4cec93d3893aa6b744468af67e672383c6770afd /widget/src/checkbox.rs | |
parent | c15f1b5f6575792cc89bb5fba2e613428397e46a (diff) | |
download | iced-34451bff185d8875f55747ee97ed746828e30f40.tar.gz iced-34451bff185d8875f55747ee97ed746828e30f40.tar.bz2 iced-34451bff185d8875f55747ee97ed746828e30f40.zip |
Implement basic cursor availability
Diffstat (limited to 'widget/src/checkbox.rs')
-rw-r--r-- | widget/src/checkbox.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index 4c8a989b..86f573dd 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -8,8 +8,8 @@ use crate::core::text; use crate::core::touch; use crate::core::widget::Tree; use crate::core::{ - Alignment, Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, - Shell, Widget, + Alignment, Clipboard, Element, Layout, Length, Pixels, Rectangle, Shell, + Widget, }; use crate::{Row, Text}; @@ -204,7 +204,7 @@ where _tree: &mut Tree, event: Event, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, @@ -212,7 +212,7 @@ where match event { Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) | Event::Touch(touch::Event::FingerPressed { .. }) => { - 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_checked)); @@ -230,11 +230,11 @@ where &self, _tree: &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() @@ -248,11 +248,10 @@ where theme: &Renderer::Theme, style: &renderer::Style, layout: Layout<'_>, - cursor_position: Point, + cursor: mouse::Cursor, _viewport: &Rectangle, ) { - let bounds = layout.bounds(); - let is_mouse_over = bounds.contains(cursor_position); + let is_mouse_over = cursor.is_over(&layout.bounds()); let mut children = layout.children(); |