summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-10 23:41:07 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-10 23:41:07 +0200
commit25e54a9acbd30799e994b6282700339e8aff7297 (patch)
tree89e6ef414f22d5874160998f8c70c9dc7c7ce280 /widget
parentc711750be7ccca6a6852d0222169ebfea04ee864 (diff)
downloadiced-25e54a9acbd30799e994b6282700339e8aff7297.tar.gz
iced-25e54a9acbd30799e994b6282700339e8aff7297.tar.bz2
iced-25e54a9acbd30799e994b6282700339e8aff7297.zip
Simplify signatures of `on_move` and `on_scroll` for `mouse_area`
Diffstat (limited to 'widget')
-rw-r--r--widget/src/mouse_area.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/widget/src/mouse_area.rs b/widget/src/mouse_area.rs
index 496afaa5..d255ac99 100644
--- a/widget/src/mouse_area.rs
+++ b/widget/src/mouse_area.rs
@@ -28,7 +28,7 @@ pub struct MouseArea<
on_middle_release: Option<Message>,
on_scroll: Option<Box<dyn Fn(mouse::ScrollDelta) -> Message + 'a>>,
on_enter: Option<Message>,
- on_move: Option<Box<dyn Fn(Point) -> Message>>,
+ on_move: Option<Box<dyn Fn(Point) -> Message + 'a>>,
on_exit: Option<Message>,
interaction: Option<mouse::Interaction>,
}
@@ -78,10 +78,10 @@ impl<'a, Message, Theme, Renderer> MouseArea<'a, Message, Theme, Renderer> {
/// The message to emit when scroll wheel is used
#[must_use]
- pub fn on_scroll<F>(mut self, on_scroll: F) -> Self
- where
- F: Fn(mouse::ScrollDelta) -> Message + 'static,
- {
+ pub fn on_scroll(
+ mut self,
+ on_scroll: impl Fn(mouse::ScrollDelta) -> Message + 'a,
+ ) -> Self {
self.on_scroll = Some(Box::new(on_scroll));
self
}
@@ -95,11 +95,8 @@ impl<'a, Message, Theme, Renderer> MouseArea<'a, Message, Theme, Renderer> {
/// The message to emit when the mouse moves in the area.
#[must_use]
- pub fn on_move<F>(mut self, build_message: F) -> Self
- where
- F: Fn(Point) -> Message + 'static,
- {
- self.on_move = Some(Box::new(build_message));
+ pub fn on_move(mut self, on_move: impl Fn(Point) -> Message + 'a) -> Self {
+ self.on_move = Some(Box::new(on_move));
self
}