pub struct EventBuilder { /* private fields */ }Expand description
Implementations§
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn key_code(self, code: KeyCode) -> Self
pub fn key_code(self, code: KeyCode) -> Self
Append a special key-press event (arrows, Enter, Esc, etc.).
Sourcepub fn key_with(self, code: KeyCode, modifiers: KeyModifiers) -> Self
pub fn key_with(self, code: KeyCode, modifiers: KeyModifiers) -> Self
Append a key-press event with modifier keys (Ctrl, Shift, Alt).
Sourcepub fn key_modifier(self, m: ModifierKey) -> Self
pub fn key_modifier(self, m: ModifierKey) -> Self
Append a modifier-only key-press event (a bare Ctrl/Shift/Alt/Super press with no accompanying character).
Mirrors what the Kitty keyboard protocol delivers when
RunConfig::report_all_keys(true)
is enabled, so widget tests can simulate modifier-only presses without
poking crossterm. The event carries KeyCode::Modifier with
KeyModifiers::NONE.
Since 0.21.0.
§Example
use slt::{EventBuilder, KeyCode, ModifierKey};
let events = EventBuilder::new()
.key_modifier(ModifierKey::LeftCtrl)
.build();
assert_eq!(events.len(), 1);Sourcepub fn click(self, x: u32, y: u32) -> Self
pub fn click(self, x: u32, y: u32) -> Self
Append a left mouse click at terminal position (x, y).
Sourcepub fn click_with(self, x: u32, y: u32, modifiers: KeyModifiers) -> Self
pub fn click_with(self, x: u32, y: u32, modifiers: KeyModifiers) -> Self
Append a left-button press at (x, y) carrying the given modifiers.
Use this to simulate Shift+click (e.g. range extension in the
calendar widget). The plain click helper
always sends KeyModifiers::NONE.
Sourcepub fn mouse_up(self, x: u32, y: u32) -> Self
pub fn mouse_up(self, x: u32, y: u32) -> Self
Append a left mouse button release at terminal position (x, y).
Sourcepub fn drag(self, x: u32, y: u32) -> Self
pub fn drag(self, x: u32, y: u32) -> Self
Append a mouse drag (movement with the left button held) at (x, y).
Sourcepub fn key_release(self, c: char) -> Self
pub fn key_release(self, c: char) -> Self
Append a key-release event for character c.
Only meaningful on terminals that emit release events (e.g. with the Kitty keyboard protocol enabled).
Sourcepub fn focus_gained(self) -> Self
pub fn focus_gained(self) -> Self
Append a terminal focus-gained event.
Sourcepub fn focus_lost(self) -> Self
pub fn focus_lost(self) -> Self
Append a terminal focus-lost event.
Sourcepub fn scroll_down(self, x: u32, y: u32) -> Self
pub fn scroll_down(self, x: u32, y: u32) -> Self
Append a scroll-down event at (x, y).