diff --git a/native/src/overlay.rs b/native/src/overlay.rs index 7c3bec32..56d055d3 100644 --- a/native/src/overlay.rs +++ b/native/src/overlay.rs @@ -6,7 +6,9 @@ pub mod menu; pub use element::Element; pub use menu::Menu; -use crate::{layout, Clipboard, Event, Hasher, Layout, Point, Size}; +use crate::event::{self, Event}; +use crate::layout; +use crate::{Clipboard, Hasher, Layout, Point, Size}; /// An interactive component that can be displayed on top of other widgets. pub trait Overlay @@ -79,6 +81,7 @@ where _messages: &mut Vec, _renderer: &Renderer, _clipboard: Option<&dyn Clipboard>, - ) { + ) -> event::Status { + event::Status::Ignored } } diff --git a/native/src/overlay/element.rs b/native/src/overlay/element.rs index e1fd9b88..3f346695 100644 --- a/native/src/overlay/element.rs +++ b/native/src/overlay/element.rs @@ -1,6 +1,8 @@ pub use crate::Overlay; -use crate::{layout, Clipboard, Event, Hasher, Layout, Point, Size, Vector}; +use crate::event::{self, Event}; +use crate::layout; +use crate::{Clipboard, Hasher, Layout, Point, Size, Vector}; /// A generic [`Overlay`]. /// @@ -67,7 +69,7 @@ where messages: &mut Vec, renderer: &Renderer, clipboard: Option<&dyn Clipboard>, - ) { + ) -> event::Status { self.overlay.on_event( event, layout, @@ -136,10 +138,10 @@ where messages: &mut Vec, renderer: &Renderer, clipboard: Option<&dyn Clipboard>, - ) { + ) -> event::Status { let mut original_messages = Vec::new(); - self.content.on_event( + let event_status = self.content.on_event( event, layout, cursor_position, @@ -151,6 +153,8 @@ where original_messages .drain(..) .for_each(|message| messages.push((self.mapper)(message))); + + event_status } fn draw( diff --git a/native/src/overlay/menu.rs b/native/src/overlay/menu.rs index 3577629b..d99b5940 100644 --- a/native/src/overlay/menu.rs +++ b/native/src/overlay/menu.rs @@ -241,15 +241,15 @@ where messages: &mut Vec, renderer: &Renderer, clipboard: Option<&dyn Clipboard>, - ) { - let _ = self.container.on_event( + ) -> event::Status { + self.container.on_event( event.clone(), layout, cursor_position, messages, renderer, clipboard, - ); + ) } fn draw( diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index 2ac4db0f..6da46115 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -216,7 +216,7 @@ where ); for event in events { - overlay.on_event( + let _ = overlay.on_event( event.clone(), Layout::new(&layer.layout), cursor_position,