Make `Overlay::on_event` return `event::Status`
This commit is contained in:
parent
3aca177132
commit
6e9bd0d9d1
|
@ -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<Message, Renderer>
|
||||
|
@ -79,6 +81,7 @@ where
|
|||
_messages: &mut Vec<Message>,
|
||||
_renderer: &Renderer,
|
||||
_clipboard: Option<&dyn Clipboard>,
|
||||
) {
|
||||
) -> event::Status {
|
||||
event::Status::Ignored
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Message>,
|
||||
renderer: &Renderer,
|
||||
clipboard: Option<&dyn Clipboard>,
|
||||
) {
|
||||
) -> event::Status {
|
||||
self.overlay.on_event(
|
||||
event,
|
||||
layout,
|
||||
|
@ -136,10 +138,10 @@ where
|
|||
messages: &mut Vec<B>,
|
||||
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(
|
||||
|
|
|
@ -241,15 +241,15 @@ where
|
|||
messages: &mut Vec<Message>,
|
||||
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(
|
||||
|
|
|
@ -216,7 +216,7 @@ where
|
|||
);
|
||||
|
||||
for event in events {
|
||||
overlay.on_event(
|
||||
let _ = overlay.on_event(
|
||||
event.clone(),
|
||||
Layout::new(&layer.layout),
|
||||
cursor_position,
|
||||
|
|
Loading…
Reference in New Issue