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
|
/// [`Event`]: enum.Event.html
|
||||||
Captured,
|
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,
|
renderer: &Renderer,
|
||||||
clipboard: Option<&dyn Clipboard>,
|
clipboard: Option<&dyn Clipboard>,
|
||||||
) -> event::Status {
|
) -> event::Status {
|
||||||
self.children.iter_mut().zip(layout.children()).for_each(
|
self.children
|
||||||
|(child, layout)| {
|
.iter_mut()
|
||||||
let _ = child.widget.on_event(
|
.zip(layout.children())
|
||||||
|
.map(|(child, layout)| {
|
||||||
|
child.widget.on_event(
|
||||||
event.clone(),
|
event.clone(),
|
||||||
layout,
|
layout,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
messages,
|
messages,
|
||||||
renderer,
|
renderer,
|
||||||
clipboard,
|
clipboard,
|
||||||
);
|
)
|
||||||
},
|
})
|
||||||
);
|
.fold(event::Status::Ignored, event::Status::merge)
|
||||||
|
|
||||||
event::Status::Ignored
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(
|
fn draw(
|
||||||
|
Loading…
Reference in New Issue
Block a user