From dcc184b01b753dbecb500205391f6eaaa21c8683 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 25 Oct 2024 19:28:18 +0200 Subject: Replace `event::Status` in `Widget::on_event` with `Shell::capture_event` --- core/src/overlay/element.rs | 13 +++++-------- core/src/overlay/group.rs | 27 +++++++++++---------------- 2 files changed, 16 insertions(+), 24 deletions(-) (limited to 'core/src/overlay') diff --git a/core/src/overlay/element.rs b/core/src/overlay/element.rs index 32e987a3..4a242213 100644 --- a/core/src/overlay/element.rs +++ b/core/src/overlay/element.rs @@ -1,11 +1,10 @@ pub use crate::Overlay; -use crate::event::{self, Event}; use crate::layout; use crate::mouse; use crate::renderer; use crate::widget; -use crate::{Clipboard, Layout, Point, Rectangle, Shell, Size}; +use crate::{Clipboard, Event, Layout, Point, Rectangle, Shell, Size}; /// A generic [`Overlay`]. #[allow(missing_debug_implementations)] @@ -58,9 +57,9 @@ where renderer: &Renderer, clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, - ) -> event::Status { + ) { self.overlay - .on_event(event, layout, cursor, renderer, clipboard, shell) + .on_event(event, layout, cursor, renderer, clipboard, shell); } /// Returns the current [`mouse::Interaction`] of the [`Element`]. @@ -157,11 +156,11 @@ where renderer: &Renderer, clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, B>, - ) -> event::Status { + ) { let mut local_messages = Vec::new(); let mut local_shell = Shell::new(&mut local_messages); - let event_status = self.content.on_event( + self.content.on_event( event, layout, cursor, @@ -171,8 +170,6 @@ where ); shell.merge(local_shell, self.mapper); - - event_status } fn mouse_interaction( diff --git a/core/src/overlay/group.rs b/core/src/overlay/group.rs index 6541d311..11ebd579 100644 --- a/core/src/overlay/group.rs +++ b/core/src/overlay/group.rs @@ -1,4 +1,3 @@ -use crate::event; use crate::layout; use crate::mouse; use crate::overlay; @@ -81,21 +80,17 @@ where renderer: &Renderer, clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, - ) -> event::Status { - self.children - .iter_mut() - .zip(layout.children()) - .map(|(child, layout)| { - child.on_event( - event.clone(), - layout, - cursor, - renderer, - clipboard, - shell, - ) - }) - .fold(event::Status::Ignored, event::Status::merge) + ) { + for (child, layout) in self.children.iter_mut().zip(layout.children()) { + child.on_event( + event.clone(), + layout, + cursor, + renderer, + clipboard, + shell, + ); + } } fn draw( -- cgit From e5f1e31a5c068fe992cab076661cb6e2d120bdf1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 6 Nov 2024 00:02:46 +0100 Subject: Rename `Overlay::on_event` to `update` --- core/src/overlay/element.rs | 8 ++++---- core/src/overlay/group.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'core/src/overlay') diff --git a/core/src/overlay/element.rs b/core/src/overlay/element.rs index 4a242213..ed870feb 100644 --- a/core/src/overlay/element.rs +++ b/core/src/overlay/element.rs @@ -49,7 +49,7 @@ where } /// Processes a runtime [`Event`]. - pub fn on_event( + pub fn update( &mut self, event: Event, layout: Layout<'_>, @@ -59,7 +59,7 @@ where shell: &mut Shell<'_, Message>, ) { self.overlay - .on_event(event, layout, cursor, renderer, clipboard, shell); + .update(event, layout, cursor, renderer, clipboard, shell); } /// Returns the current [`mouse::Interaction`] of the [`Element`]. @@ -148,7 +148,7 @@ where self.content.operate(layout, renderer, operation); } - fn on_event( + fn update( &mut self, event: Event, layout: Layout<'_>, @@ -160,7 +160,7 @@ where let mut local_messages = Vec::new(); let mut local_shell = Shell::new(&mut local_messages); - self.content.on_event( + self.content.update( event, layout, cursor, diff --git a/core/src/overlay/group.rs b/core/src/overlay/group.rs index 11ebd579..2b374252 100644 --- a/core/src/overlay/group.rs +++ b/core/src/overlay/group.rs @@ -72,7 +72,7 @@ where ) } - fn on_event( + fn update( &mut self, event: Event, layout: Layout<'_>, @@ -82,7 +82,7 @@ where shell: &mut Shell<'_, Message>, ) { for (child, layout) in self.children.iter_mut().zip(layout.children()) { - child.on_event( + child.update( event.clone(), layout, cursor, -- cgit