Skip to main content

Module text

Module text 

Source
Expand description

The engine’s reserved text context: the keys a text field takes while it is being typed into, so that they reach neither the UI’s navigation nor the game.

One action, bound to every key that types or edits: the letters, the digits, the punctuation row and the ISO and JIS extra keys, Space, the numpad’s digits and operators, Backspace and Delete, Home and End, and Left and Right. Nothing reads TYPE’s value — the characters arrive as the shell’s TextCommit with the layout applied, and the edits come from the key events themselves — it exists so the context owns those keys, and the context stack’s rule that the topmost active context binding an input consumes it does the rest.

Pushed over ui::CONTEXT while a text field is engaged, and popped when it is not. While it is pushed W, A, S, D and the arrows are no ui_move, Space is no ui_accept, and a game’s binding on any of them hears nothing. Enter, Escape and Tab are not bound, so they still fall through to ui_accept, ui_back and ui_next — which is how a field is committed, cancelled or left. The Up and Down arrows are not bound either: a single-line field has no use for them, and an engaged widget already takes navigation steps instead of focus.

A key held when the context is pushed is withheld from it until released, as for every push: the Space that engaged a field is not then also typed into it by this context, and a W held since before the field engaged goes up for the game and stays silent here.

Constants§

CONTEXT
The reserved context’s name.
KEYS
Every key CONTEXT takes.
TYPE
The one action: a key a text field takes. See the module docs.

Functions§

declare
Declare the reserved text context into map, off the stack.
sync
Puts CONTEXT on map’s stack while editing, and takes it off when not: what a caller runs once a frame with Ui::text_editing’s answer. Does nothing when the stack already agrees.