summaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-13 06:58:53 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-04-13 06:58:53 +0200
commit0c39112a2e7c63e7f8c2a03e67216b3736cb3aeb (patch)
tree1fde7261eee469e000f7f8281e5df8bc92d548d9 /native/src
parent020f1120e332b450f12ccf7aa3f4a52c5ee282a8 (diff)
downloadiced-0c39112a2e7c63e7f8c2a03e67216b3736cb3aeb.tar.gz
iced-0c39112a2e7c63e7f8c2a03e67216b3736cb3aeb.tar.bz2
iced-0c39112a2e7c63e7f8c2a03e67216b3736cb3aeb.zip
Remove support for `on_mouse_enter` and `on_mouse_exit` in `MouseArea`
These need continuity guarantees (e.g. mandatory widget id), which we don't have yet!
Diffstat (limited to 'native/src')
-rw-r--r--native/src/widget/mouse_area.rs48
1 files changed, 3 insertions, 45 deletions
diff --git a/native/src/widget/mouse_area.rs b/native/src/widget/mouse_area.rs
index 5bf096d3..69cfddbf 100644
--- a/native/src/widget/mouse_area.rs
+++ b/native/src/widget/mouse_area.rs
@@ -21,8 +21,6 @@ pub struct MouseArea<'a, Message, Renderer> {
on_right_release: Option<Message>,
on_middle_press: Option<Message>,
on_middle_release: Option<Message>,
- on_mouse_enter: Option<Message>,
- on_mouse_exit: Option<Message>,
}
impl<'a, Message, Renderer> MouseArea<'a, Message, Renderer> {
@@ -67,26 +65,12 @@ impl<'a, Message, Renderer> MouseArea<'a, Message, Renderer> {
self.on_middle_release = Some(message);
self
}
-
- /// The message to emit when the mouse enters the widget.
- #[must_use]
- pub fn on_mouse_enter(mut self, message: Message) -> Self {
- self.on_mouse_enter = Some(message);
- self
- }
-
- /// The messsage to emit when the mouse exits the widget.
- #[must_use]
- pub fn on_mouse_exit(mut self, message: Message) -> Self {
- self.on_mouse_exit = Some(message);
- self
- }
}
/// Local state of the [`MouseArea`].
#[derive(Default)]
struct State {
- is_hovered: bool,
+ // TODO: Support on_mouse_enter and on_mouse_exit
}
impl<'a, Message, Renderer> MouseArea<'a, Message, Renderer> {
@@ -100,8 +84,6 @@ impl<'a, Message, Renderer> MouseArea<'a, Message, Renderer> {
on_right_release: None,
on_middle_press: None,
on_middle_release: None,
- on_mouse_enter: None,
- on_mouse_exit: None,
}
}
}
@@ -181,14 +163,7 @@ where
return event::Status::Captured;
}
- update(
- self,
- &event,
- layout,
- cursor_position,
- shell,
- tree.state.downcast_mut::<State>(),
- )
+ update(self, &event, layout, cursor_position, shell)
}
fn mouse_interaction(
@@ -264,28 +239,11 @@ fn update<Message: Clone, Renderer>(
layout: Layout<'_>,
cursor_position: Point,
shell: &mut Shell<'_, Message>,
- state: &mut State,
) -> event::Status {
- let was_hovered = state.is_hovered;
-
- state.is_hovered = layout.bounds().contains(cursor_position);
-
- if !state.is_hovered {
- if was_hovered {
- if let Some(message) = widget.on_mouse_exit.as_ref() {
- shell.publish(message.clone());
- }
- }
-
+ if !layout.bounds().contains(cursor_position) {
return event::Status::Ignored;
}
- if !was_hovered {
- if let Some(message) = widget.on_mouse_enter.as_ref() {
- shell.publish(message.clone());
- }
- }
-
if let Some(message) = widget.on_press.as_ref() {
if let Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
| Event::Touch(touch::Event::FingerPressed { .. }) = event