Keyboard
Keyboard shown on textarea focus
Hide the keyboard unless one of two textareas is focused.
Two textareas are placed at the top-left and top-right, one with placeholder
text Hello. A shared callback watches LV_EVENT_FOCUSED and
LV_EVENT_DEFOCUSED: on focus it retargets the keyboard with
lv_keyboard_set_textarea and clears LV_OBJ_FLAG_HIDDEN, and on defocus it
clears the target and hides the keyboard again.
AZERTY layout as USER_1 mode
Register a custom AZERTY button map on the keyboard.
A kb_map and matching lv_buttonmatrix_ctrl_t control array describe an
AZERTY layout with LV_SYMBOL_BACKSPACE, LV_SYMBOL_NEW_LINE,
LV_SYMBOL_CLOSE, and LV_SYMBOL_OK. lv_keyboard_set_map installs the
layout under LV_KEYBOARD_MODE_USER_1 and lv_keyboard_set_mode activates
it. A focused textarea above the keyboard receives the typed characters.
Per-button colors via draw task hook
Recolor each keyboard key and swap the OK symbol for a star image.
A centered lv_keyboard has LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS set and a
LV_EVENT_DRAW_TASK_ADDED callback attached. For every LV_PART_ITEMS draw
task the handler picks a palette entry from base_dsc->id1, darkens it while
the button is in LV_STATE_PRESSED, and lightens the label text. When the
task is drawing LV_SYMBOL_OK the label is hidden and img_star is drawn in
its place.
How is this guide?
Last updated on