summaryrefslogtreecommitdiffstats
path: root/native/src/event.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/event.rs')
-rw-r--r--native/src/event.rs42
1 files changed, 37 insertions, 5 deletions
diff --git a/native/src/event.rs b/native/src/event.rs
index 99a8e880..f3c260c0 100644
--- a/native/src/event.rs
+++ b/native/src/event.rs
@@ -1,7 +1,8 @@
-use crate::{
- input::{keyboard, mouse, Touch},
- window,
-};
+//! Handle events of a user interface.
+use crate::keyboard;
+use crate::mouse;
+use crate::touch;
+use crate::window;
/// A user interface event.
///
@@ -21,5 +22,36 @@ pub enum Event {
Window(window::Event),
/// A touch event
- Touch(Touch),
+ Touch(touch::Touch),
+}
+
+/// The status of an [`Event`] after being processed.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Status {
+ /// The [`Event`] was **NOT** handled by any widget.
+ Ignored,
+
+ /// The [`Event`] was handled and processed by a widget.
+ 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,
+ }
+ }
}