summaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-18 16:59:42 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-18 16:59:42 +0700
commit4f5f444d7c507105d025471fbe930e50653c05bf (patch)
treea06a8171c0f935186cfc1c5f6068306520742eb0 /native/src
parent9a4fb82b5818f10e96d2f185a7e5a1f1fce3305c (diff)
downloadiced-4f5f444d7c507105d025471fbe930e50653c05bf.tar.gz
iced-4f5f444d7c507105d025471fbe930e50653c05bf.tar.bz2
iced-4f5f444d7c507105d025471fbe930e50653c05bf.zip
Implement `Widget::mouse_interaction` for `Button`
Diffstat (limited to 'native/src')
-rw-r--r--native/src/widget/button.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs
index a05210fd..a654cf12 100644
--- a/native/src/widget/button.rs
+++ b/native/src/widget/button.rs
@@ -245,6 +245,22 @@ where
event::Status::Ignored
}
+ fn mouse_interaction(
+ &self,
+ layout: Layout<'_>,
+ _viewport: &Rectangle,
+ cursor_position: Point,
+ ) -> mouse::Interaction {
+ let is_mouse_over = layout.bounds().contains(cursor_position);
+ let is_disabled = self.on_press.is_none();
+
+ if is_mouse_over && !is_disabled {
+ mouse::Interaction::Pointer
+ } else {
+ mouse::Interaction::default()
+ }
+ }
+
fn draw(
&self,
renderer: &mut Renderer,
@@ -257,8 +273,9 @@ where
let content_layout = layout.children().next().unwrap();
let is_mouse_over = bounds.contains(cursor_position);
+ let is_disabled = self.on_press.is_none();
- let styling = if self.on_press.is_none() {
+ let styling = if is_disabled {
self.style_sheet.disabled()
} else if is_mouse_over {
if self.state.is_pressed {