summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-20 16:28:27 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-20 16:28:27 +0700
commit954d6349a8cd5505d99403285ce9617c65a63a2b (patch)
treefab0e5663ad5561b91d0389393d84a6a170f7c1c
parentc800fd07c3460d90a120fe30fc0cd7503d829f68 (diff)
downloadiced-954d6349a8cd5505d99403285ce9617c65a63a2b.tar.gz
iced-954d6349a8cd5505d99403285ce9617c65a63a2b.tar.bz2
iced-954d6349a8cd5505d99403285ce9617c65a63a2b.zip
Implement `Widget::mouse_interaction` for `Slider`
-rw-r--r--native/src/widget/slider.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs
index 31a5965b..60124160 100644
--- a/native/src/widget/slider.rs
+++ b/native/src/widget/slider.rs
@@ -336,6 +336,24 @@ where
});
}
+ fn mouse_interaction(
+ &self,
+ layout: Layout<'_>,
+ _viewport: &Rectangle,
+ cursor_position: Point,
+ ) -> mouse::Interaction {
+ let bounds = layout.bounds();
+ let is_mouse_over = bounds.contains(cursor_position);
+
+ if self.state.is_dragging {
+ mouse::Interaction::Grabbing
+ } else if is_mouse_over {
+ mouse::Interaction::Grab
+ } else {
+ mouse::Interaction::default()
+ }
+ }
+
fn hash_layout(&self, state: &mut Hasher) {
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);