Struct cursive_core::event::EventTrigger
source · pub struct EventTrigger { /* private fields */ }
Expand description
A trigger that only selects some types of events.
It is meant to be stored in views.
Implementations§
source§impl EventTrigger
impl EventTrigger
sourcepub fn from_fn<F>(f: F) -> Selfwhere
F: 'static + Fn(&Event) -> bool,
pub fn from_fn<F>(f: F) -> Selfwhere
F: 'static + Fn(&Event) -> bool,
Create a new EventTrigger
using the given function as filter.
sourcepub fn from_fn_and_tag<F, T>(f: F, tag: T) -> Selfwhere
F: 'static + Fn(&Event) -> bool,
T: Any + Debug,
pub fn from_fn_and_tag<F, T>(f: F, tag: T) -> Selfwhere
F: 'static + Fn(&Event) -> bool,
T: Any + Debug,
Create a new EventTrigger
.
sourcepub fn has_tag<T: PartialEq + 'static>(&self, tag: &T) -> bool
pub fn has_tag<T: PartialEq + 'static>(&self, tag: &T) -> bool
Check if this trigger has the given tag.
Examples
use cursive_core::event::{Event, EventTrigger};
let event = Event::CtrlChar('c');
let trigger: EventTrigger = event.clone().into();
assert!(
trigger.has_tag(&event),
"Trigger does not recognize its own tag."
);
sourcepub fn arrows() -> Self
pub fn arrows() -> Self
Returns an EventTrigger
that only accepts arrow keys.
Only bare arrow keys without modifiers (Shift, Ctrl, Alt) will be accepted.
sourcepub fn or<O>(self, other: O) -> Selfwhere
O: Into<EventTrigger>,
pub fn or<O>(self, other: O) -> Selfwhere
O: Into<EventTrigger>,
Returns an EventTrigger
that applies if either self
or other
applies.