Struct termimad::TimedEvent
source · pub struct TimedEvent {
pub time: Instant,
pub event: Event,
pub double_click: bool,
pub key_combination: Option<KeyCombination>,
}
Expand description
A user event based on a crossterm event, decorated
- with time
- with a double_click flag
- with a KeyCombination, if the event is a key ending a combination (which may be a simple key)
You normally don’t build this yourself, but rather use the [EventSource].
Fields§
§time: Instant
§event: Event
§double_click: bool
false unless you set it yourself using the time or you get the timed event with an EventSource which computes it. Can be true only for left mouse down and left mouse up (both down and up of the second click have it true)
key_combination: Option<KeyCombination>
If you’re interested in key combinations, you should prefer this field over the Key variant of the event field. If you want to react on Press or Repeat, then the event field holds the information.
Implementations§
source§impl TimedEvent
impl TimedEvent
sourcepub fn new(event: Event) -> Self
pub fn new(event: Event) -> Self
Wrap a crossterm event into a timed one, with time.
You should normally not need to use this function, but rather obtain the timed event from an EventSource which build the normalized key combination, and sets the double_click flag.
sourcepub fn as_click(&self) -> Option<(u16, u16)>
pub fn as_click(&self) -> Option<(u16, u16)>
If it’s a simple mouse up and not determined to be the second click of a double click, return the coordinates
pub fn is_key<K: Into<KeyCombination>>(&self, key: K) -> bool
Trait Implementations§
source§impl Clone for TimedEvent
impl Clone for TimedEvent
source§fn clone(&self) -> TimedEvent
fn clone(&self) -> TimedEvent
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TimedEvent
impl Debug for TimedEvent
source§impl PartialEq for TimedEvent
impl PartialEq for TimedEvent
source§fn eq(&self, other: &TimedEvent) -> bool
fn eq(&self, other: &TimedEvent) -> bool
self
and other
values to be equal, and is used
by ==
.