Keys and focus#

Declared in ui.h. See keys and focus for the key table and how navigation works.

Key codes are the ones of os_GetCSC, such as sk_Up, sk_Enter, sk_Clear and sk_Graph, from <ti/getcsc.h>, which ui.h includes.

ui_key#

uint8_t ui_key(void);

Returns the key event of this frame if no widget has used it so far, or 0. It does not use the key up; call it after the widgets that should see the key first.

ui_key_pressed#

bool ui_key_pressed(uint8_t key);

Checks for one key and uses it up.

Parameter

Meaning

key

A key code such as sk_Clear

Returns true when key is this frame’s event and no widget used it. The key is then used up, so later widgets and later calls do not see it, and a settle frame runs.

ui_listen#

void ui_listen(void);

Reads the keypad and queues new presses, up to 4. Call it now and then from program code that runs for long between widgets, so a short press during that time is not lost. CEUI does the same on its own while it waits, every fourth widget and before every rectangle it draws.

ui_next_id#

void ui_next_id(int id);

Sets the id of the next widget, instead of the one taken from its label or state pointer. Use it for a button whose label changes, or for buttons with the same label in one container. The number is mixed with the container’s id, so it only has to be unique within the container. It applies to one widget.

Parameter

Meaning

id

Any number

ui_enabled#

void ui_enabled(bool enabled);

Enables or disables every widget placed after it, until it is called again. Disabled widgets are drawn in their UI_DISABLED colors, ignore keys and cannot take focus. Every frame starts enabled.

Parameter

Meaning

enabled

false to disable the following widgets, true to enable them again

ui_focus_here#

void ui_focus_here(void);

Gives focus to the next focusable widget. Call it in one frame only, for example the first frame of a form. In the frame a modal or menu closes, it wins over the focus that would be restored.

ui_focused#

bool ui_focused(void);

Returns true when the widget placed last has focus. Use it to show help for the focused field.

Softkey numbers#

enum { UI_F1, UI_F2, UI_F3, UI_F4, UI_F5, UI_SOFTKEYS };

UI_F1 to UI_F5 are the values ui_softkeys returns for the keys [y=], [window], [zoom], [trace] and [graph]. UI_SOFTKEYS (5) is the number of softkeys, the size of the label array ui_softkeys takes. See ui_softkeys.