Expand description
One focus convention for every form and dialog.
A form is an ordered list of fields, each of a FieldKind. A modal says which
fields it shows right now and which one has focus (Form); this module moves
focus and decides what a key means, so every dialog answers the same keys the
same way:
| Key | Does |
|---|---|
| Tab / Shift+Tab, ↓ / ↑ | next / previous field, wrapping |
| ← / → | step a choice; move the cursor in a text field |
| Space | toggle a checkbox, next value of a choice, open a picker, press a button |
| Enter | submit, from any field (a multiline field types it; Ctrl+J submits) |
| Esc | cancel the form (an open picker closes first: picker_key) |
| Ctrl+P / Ctrl+N | history in a text field |
h j k l are the arrows on a field that does not type. What a submit, a
step or an action does stays with the modal: key says which happened, to
which field.
Enums§
- Field
Kind - How a field takes keys.
- FormKey
- What a key did to a form, for the modal to carry out.
- List
Move - A move of a list’s cursor, from the keys every list answers: ↑ /
k, ↓ /j, PageUp, PageDown, Home and End. - Picker
Key - What a key did in an open picker.
Traits§
- Form
- A form: its fields in order and the one with focus. The modal owns both; the default methods move focus the same way for every form.
Functions§
- key
- What
eventdoes toformwhile no picker is open. Focus moves happen here; everything else is returned for the modal to do. - picker_
form_ key eventin a form with a picker open: the picker takes it (picker_key), choosing, toggling or closing through the form. Returns whether a picker was open.- picker_
key - What
eventdoes in an open picker: type to narrow, ↑↓ move, Space chooses (or toggles in a list of several), Enter chooses, Esc closes the picker only. In a pick-one list Space chooses only while the filter is empty, and types a space once it narrows, so a name of several words can be typed; with nothing typed it would match nothing and blank the list under the key that opened it. - step_
index - Index
atstepped bydeltathroughlenvalues, wrapping. - step_
value currentstepped bydeltathroughall, wrapping; the first value whencurrentis not among them.