TUIX v0.5Beta
Input Handling
TUIX captures keyboard and mouse events on a native listener thread and exposes them as snapshots. The frame loop routes snapshots to the focused, captured, modal, or hitmap-picked widget.
Starting And Stopping
from tuix.core import input
input.listen()
# run engine.main_loop()
input.stop()Snapshots
| Function | Behavior |
|---|---|
| input.get_snapshot() | Returns and consumes the next snapshot. |
| input.peek_snapshot() | Returns the latest snapshot without consuming queued events when supported. |
Snapshot Shape
- InputSnapshot exposes term_x, term_y, keyboard, mouse, consumed_keyboard, and consumed_mouse.
- Keyboard events expose fields such as btn, code, scancode, modifiers, pressed, repeat, and has_event.
- Mouse events expose event, btn, buttons_held, col, row, and has_event.
Routing Order
v0.5 routing accounts for modal state, mouse capture, viewport ownership, hitmap picking, focus, and generic mouse handling. This matters for drag-heavy widgets and scrollable containers, where the visible content target can differ from the original buffer position.
Mouse Capture
from tuix.core import engine
engine.mouse_capture_begin(uid)
active_uid = engine.get_mouse_capture_uid()
engine.mouse_capture_end(uid)