pub enum Event {
Key(KeyEvent),
Paste(String),
Mouse(MouseEvent),
Tick,
Resize(Size),
}Expand description
Unified input events for Component::on_event.
Wraps the raw crossterm event types into a smaller, focused set. Convert from crossterm::event::Event using TryFrom — this filters out key releases and maps resize events automatically.
§Variants
Key(KeyEvent)— A key press or repeat. Key releases are filtered out during conversion.Paste(String)— Bracketed paste content (requiresTerminalSessionwith bracketed paste enabled).Mouse(MouseEvent)— Mouse input (scroll, click, drag). Requires mouse capture.Tick— A periodic timer tick, useful for animations (e.g.Spinner).Resize(Size)— The terminal was resized to a newSize.
§Conversion
use tui::Event;
use crossterm::event::Event as CrosstermEvent;
fn poll_event(raw: CrosstermEvent) -> Option<Event> {
Event::try_from(raw).ok()
}The TryFrom conversion returns Err(()) for events that components should not handle (key releases, focus gained/lost).
Variants§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more