Guide API
Skip to main content

Module event

Module event 

Source
Expand description

Events — the Event enum and the key/mouse records that fill it.

Event is the sum type a View matches arm-by-arm: mouse presses/releases/moves/wheel, key presses, commands, broadcasts, timer expiries, and paste. The keyboard side lives in the key submodule (Key, KeyEvent, KeyModifiers); the mouse record (MouseEvent) and the EventMask opt-in for expensive event classes live here.

Two events carry payloads worth naming up front. Event::Broadcast adds an optional source: ViewId naming which view the broadcast is about (e.g. which scrollbar changed) — a resolvable handle, None for broadcasts about no particular view. Event::Timer carries which TimerId expired.

One primitive is deliberately not reproduced: a synchronous, return-valued message round-trip (the kind used for “may I close?” vetoes). A view here is borrowed downward by the event loop and cannot synchronously call back into a sibling and read a return value, so there is no event that carries a reply. Code that needs that pattern queries the tree owner directly via find_mut instead.

Guide: Commands & events.

§Turbo Vision heritage

Replaces the single TEvent tagged union (system.h) with a Rust sum type (deviation D4). The original message event carried a command plus an untyped pointer used three ways; here a command event carries only the Command, the “which view” case becomes Event::Broadcast’s resolvable ViewId source, and the timer-id case becomes the typed Event::Timer variant.

Structs§

EventMask
Per-view opt-in mask for the expensive continuous event classes.
KeyEvent
A key-down event: the logical Key that was pressed plus the KeyModifiers held at that moment.
KeyModifiers
The keyboard modifiers active when a key or mouse event occurred — a struct of three named bool flags.
MouseButtons
Which mouse buttons are currently held at the time of a MouseEvent.
MouseEvent
A mouse event record: cursor position, buttons down, wheel direction, click/move flags, and keyboard modifiers held at event time.
MouseEventFlags
Per-event flags for click-repeat detection and movement — a struct of named bool flags carried in every MouseEvent.

Enums§

Event
An event a View handles, matched arm-by-arm.
Key
A logical, modifier-free key — the base of a KeyEvent.
MouseWheel
The direction of mouse wheel motion carried by a MouseEvent.

Functions§

ctrl_to_arrow
Map WordStar Ctrl-letter navigation keys to their arrow/nav equivalents.
hot_key
Extract the hotkey character from a label string.
is_alt_hotkey
Test whether a key event is the Alt-accelerator for a given hotkey char.
is_plain_hotkey
Test whether a key event is a plain (non-modified) hotkey press.