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 element::Element;
|
||||||
pub use menu::Menu;
|
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.
|
/// An interactive component that can be displayed on top of other widgets.
|
||||||
pub trait Overlay<Message, Renderer>
|
pub trait Overlay<Message, Renderer>
|
||||||
|
@ -79,6 +81,7 @@ where
|
||||||
_messages: &mut Vec<Message>,
|
_messages: &mut Vec<Message>,
|
||||||
_renderer: &Renderer,
|
_renderer: &Renderer,
|
||||||
_clipboard: Option<&dyn Clipboard>,
|
_clipboard: Option<&dyn Clipboard>,
|
||||||
) {
|
) -> event::Status {
|
||||||
|
event::Status::Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
pub use crate::Overlay;
|
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`].
|
/// A generic [`Overlay`].
|
||||||
///
|
///
|
||||||
|
@ -67,7 +69,7 @@ where
|
||||||
messages: &mut Vec<Message>,
|
messages: &mut Vec<Message>,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: Option<&dyn Clipboard>,
|
clipboard: Option<&dyn Clipboard>,
|
||||||
) {
|
) -> event::Status {
|
||||||
self.overlay.on_event(
|
self.overlay.on_event(
|
||||||
event,
|
event,
|
||||||
layout,
|
layout,
|
||||||
|
@ -136,10 +138,10 @@ where
|
||||||
messages: &mut Vec<B>,
|
messages: &mut Vec<B>,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: Option<&dyn Clipboard>,
|
clipboard: Option<&dyn Clipboard>,
|
||||||
) {
|
) -> event::Status {
|
||||||
let mut original_messages = Vec::new();
|
let mut original_messages = Vec::new();
|
||||||
|
|
||||||
self.content.on_event(
|
let event_status = self.content.on_event(
|
||||||
event,
|
event,
|
||||||
layout,
|
layout,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
@ -151,6 +153,8 @@ where
|
||||||
original_messages
|
original_messages
|
||||||
.drain(..)
|
.drain(..)
|
||||||
.for_each(|message| messages.push((self.mapper)(message)));
|
.for_each(|message| messages.push((self.mapper)(message)));
|
||||||
|
|
||||||
|
event_status
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(
|
fn draw(
|
||||||
|
|
|
@ -241,15 +241,15 @@ where
|
||||||
messages: &mut Vec<Message>,
|
messages: &mut Vec<Message>,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: Option<&dyn Clipboard>,
|
clipboard: Option<&dyn Clipboard>,
|
||||||
) {
|
) -> event::Status {
|
||||||
let _ = self.container.on_event(
|
self.container.on_event(
|
||||||
event.clone(),
|
event.clone(),
|
||||||
layout,
|
layout,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
messages,
|
messages,
|
||||||
renderer,
|
renderer,
|
||||||
clipboard,
|
clipboard,
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(
|
fn draw(
|
||||||
|
|
|
@ -216,7 +216,7 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
for event in events {
|
for event in events {
|
||||||
overlay.on_event(
|
let _ = overlay.on_event(
|
||||||
event.clone(),
|
event.clone(),
|
||||||
Layout::new(&layer.layout),
|
Layout::new(&layer.layout),
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
|
Loading…
Reference in New Issue