#[non_exhaustive]pub enum Event {
Key(KeyEvent),
Mouse(MouseEvent),
Resize(u32, u32),
Paste(String),
FocusGained,
FocusLost,
}Expand description
A terminal input event.
Produced each frame by the run loop and passed to your UI closure via
crate::Context. Use the helper methods on Context (e.g., key(),
key_code()) rather than matching on this type directly.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Key(KeyEvent)
A keyboard event.
Mouse(MouseEvent)
A mouse event (requires mouse: true in crate::RunConfig).
Resize(u32, u32)
The terminal was resized to the given (columns, rows).
Paste(String)
Pasted text (bracketed paste). May contain newlines.
FocusGained
The terminal window gained focus.
FocusLost
The terminal window lost focus. Used to clear hover state.
Implementations§
Source§impl Event
impl Event
Sourcepub fn key_mod(code: KeyCode, modifiers: KeyModifiers) -> Self
pub fn key_mod(code: KeyCode, modifiers: KeyModifiers) -> Self
Create a key press event with custom modifiers.
Sourcepub fn mouse_click(x: u32, y: u32) -> Self
pub fn mouse_click(x: u32, y: u32) -> Self
Create a left mouse click event at (x, y).
Sourcepub fn mouse_move(x: u32, y: u32) -> Self
pub fn mouse_move(x: u32, y: u32) -> Self
Create a mouse move event at the given position.
Sourcepub fn mouse_drag(x: u32, y: u32) -> Self
pub fn mouse_drag(x: u32, y: u32) -> Self
Create a left mouse drag event at (x, y).
Sourcepub fn scroll_down(x: u32, y: u32) -> Self
pub fn scroll_down(x: u32, y: u32) -> Self
Create a scroll down event at the given position.
Sourcepub fn key_release(c: char) -> Self
pub fn key_release(c: char) -> Self
Create a key release event for a character.
Sourcepub fn as_mouse(&self) -> Option<&MouseEvent>
pub fn as_mouse(&self) -> Option<&MouseEvent>
Returns the mouse event data if this is a Mouse variant.
Trait Implementations§
impl Eq for Event
impl StructuralPartialEq for Event
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.