Enum cursive_core::event::EventResult
source · Expand description
Answer to an event notification. The event can be consumed or ignored.
Variants§
Ignored
The event was ignored. The parent can keep handling it.
Consumed(Option<Callback>)
The event was consumed. An optional callback to run is attached.
Implementations§
source§impl EventResult
impl EventResult
sourcepub fn with_cb<F>(f: F) -> Selfwhere
F: 'static + Fn(&mut Cursive),
pub fn with_cb<F>(f: F) -> Selfwhere
F: 'static + Fn(&mut Cursive),
Convenient method to create Consumed(Some(f))
sourcepub fn with_cb_once<F>(f: F) -> Selfwhere
F: 'static + FnOnce(&mut Cursive),
pub fn with_cb_once<F>(f: F) -> Selfwhere
F: 'static + FnOnce(&mut Cursive),
Convenient method to create Consumed(Some(f))
After being called once, the callback will become a no-op.
sourcepub fn is_consumed(&self) -> bool
pub fn is_consumed(&self) -> bool
Returns true
if self
is EventResult::Consumed
.
sourcepub fn has_callback(&self) -> bool
pub fn has_callback(&self) -> bool
Returns true
if self
contains a callback.
sourcepub fn process(self, s: &mut Cursive)
pub fn process(self, s: &mut Cursive)
Process this result if it is a callback.
Does nothing otherwise.
sourcepub fn or_else<F>(self, f: F) -> Selfwhere
F: FnOnce() -> EventResult,
pub fn or_else<F>(self, f: F) -> Selfwhere
F: FnOnce() -> EventResult,
Returns self
if it is not EventResult::Ignored
, otherwise returns f()
.