KeyBox
A box that captures the next key or mouse button as a binding.
let mut aim = KeyBinding::Key(KeyCode::KeyE);
ui.add(KeyBox::new(&mut aim, "Aim key"));
// or
ui.key_box(&mut aim, "Aim key");Click the box to start listening; it reads ... and pulses. The next key press binds,
Escape or a press elsewhere cancels, Backspace or Delete unbinds, and the secondary and
middle mouse buttons bind as RMB and MMB. The primary button binds only with
allow_left_click(true). changed() is set on the pass that changes the binding. Only
one box listens at a time.
KeyBinding (None, Key(KeyCode), Mouse(MouseBinding)) gives label() (A, RShift, LMB, ...), is_none(),
is_down(&InputState) and is_pressed(&InputState). While a box listens,
Context::key_capture_active() is true; hotkeys that would otherwise fire should ignore
input meanwhile. Builders: id_source, enabled, allow_left_click, button_size,
fill, active_fill, accent.
Accessibility
Role Button, named by its label; the value is the current binding. It is toggled while
it waits for a key. A Click request starts capture like a pointer click.
See Accessibility.
Recording a shortcut
KeyBox::chord(&mut chord, label) records a Chord: a key with the modifiers held, and with
.sequence(true) a second stroke after it (taken as one stroke when none comes within the chord
timeout). Backspace or Delete clears it, Escape or a press elsewhere cancels. The key is recorded
as the keymap will match it, so the result works on any layout. Pair it with Keymap::rebind and
Keymap::conflicts; the actions example is a rebinding window built this way.