class
TUI::KeyMenu
- TUI::KeyMenu
- Reference
- Object
Overview
An ordered registry of {trigger, label, action} bindings backing
BOTH key dispatch and the status-bar hint describing those same
bindings, so the two can't drift — #hint is generated from exactly
the data #dispatch uses, gated by the same when: predicate.
Deliberately excludes MouseClick: a click has no stable "label" and
needs widget-specific coordinate math, which stays where it already
lives (Window/SplitWindow).
Defined in:
tui/widget/key_menu.crConstructors
Instance Method Summary
-
#bind(trigger : Key | Char, label : String | -> String, when condition : -> Bool | Nil = nil, &action : KeyEvent -> _) : Nil
actionreceives the matched KeyEvent — ignore it ({ do_thing }) if the binding doesn't need it. -
#dispatch(ev : KeyEvent) : Bool
Tries every active binding in registration order.
-
#hint : String
Ordered, space-joined hint text for every currently-active binding (when: true or absent) — same data + same gate as #dispatch, so dispatch and displayed hint can never drift apart.
Constructor Detail
Instance Method Detail
action receives the matched KeyEvent — ignore it ({ do_thing })
if the binding doesn't need it. Matching always consumes the event;
a binding that wants to conditionally decline should use when:.
label is either a fixed String (the common case) or a -> String
for a binding whose hint text itself depends on runtime state (e.g.
"h:hide"/"h:show" toggling with what it would currently do) —
re-evaluated on every #hint call, same as when:.
Tries every active binding in registration order. Returns true (consumed) on the first match; false if nothing matched.
Ordered, space-joined hint text for every currently-active binding (when: true or absent) — same data + same gate as #dispatch, so dispatch and displayed hint can never drift apart.