Implement event capturing for Column
This commit is contained in:
parent
04468a7147
commit
3bcee62beb
@ -35,3 +35,24 @@ pub enum Status {
|
||||
/// [`Event`]: enum.Event.html
|
||||
Captured,
|
||||
}
|
||||
|
||||
impl Status {
|
||||
/// Merges two [`Status`] into one.
|
||||
///
|
||||
/// `Captured` takes precedence over `Ignored`:
|
||||
///
|
||||
/// ```
|
||||
/// use iced_native::event::Status;
|
||||
///
|
||||
/// assert_eq!(Status::Ignored.merge(Status::Ignored), Status::Ignored);
|
||||
/// assert_eq!(Status::Ignored.merge(Status::Captured), Status::Captured);
|
||||
/// assert_eq!(Status::Captured.merge(Status::Ignored), Status::Captured);
|
||||
/// assert_eq!(Status::Captured.merge(Status::Captured), Status::Captured);
|
||||
/// ```
|
||||
pub fn merge(self, b: Self) -> Self {
|
||||
match self {
|
||||
Status::Ignored => b,
|
||||
Status::Captured => Status::Captured,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,20 +163,20 @@ where
|
||||
renderer: &Renderer,
|
||||
clipboard: Option<&dyn Clipboard>,
|
||||
) -> event::Status {
|
||||
self.children.iter_mut().zip(layout.children()).for_each(
|
||||
|(child, layout)| {
|
||||
let _ = child.widget.on_event(
|
||||
self.children
|
||||
.iter_mut()
|
||||
.zip(layout.children())
|
||||
.map(|(child, layout)| {
|
||||
child.widget.on_event(
|
||||
event.clone(),
|
||||
layout,
|
||||
cursor_position,
|
||||
messages,
|
||||
renderer,
|
||||
clipboard,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
event::Status::Ignored
|
||||
)
|
||||
})
|
||||
.fold(event::Status::Ignored, event::Status::merge)
|
||||
}
|
||||
|
||||
fn draw(
|
||||
|
Loading…
Reference in New Issue
Block a user