Fix for keyboard

This commit is contained in:
Ken Van Hoeylandt 2026-08-08 23:46:52 +02:00
parent 6b68e9f194
commit 9c54ac4944
2 changed files with 15 additions and 10 deletions

View File

@ -50,11 +50,10 @@ void lvgl_keyboard_enable(lv_indev_t* indev);
void lvgl_keyboard_disable(lv_indev_t* indev);
/**
* @brief Wires a textarea up to the on-screen keyboard: shows it on focus, hides it on
* defocus/ready, and adds the textarea to the keyboard's navigation group.
*
* No-op if lvgl_software_keyboard_is_enabled() is false (i.e. a hardware keyboard is present).
*
* @brief Adds the textarea to the shared keyboard navigation group (so any keypad indev -
* hardware or on-screen - can type into it once it's focused), and, only when
* lvgl_software_keyboard_is_enabled() is true (i.e. no hardware keyboard is present), wires it
* up to show/hide the on-screen keyboard on focus/defocus/ready.
* @warning Caller must hold the LVGL lock.
* @param[in] keyboard the on-screen keyboard to associate with the textarea
* @param[in] textarea the lv_textarea_t object to wire up

View File

@ -177,16 +177,22 @@ LvglSoftwareKeyboard* lvgl_software_keyboard_get_last() {
}
void lvgl_keyboard_add_textarea(LvglSoftwareKeyboard* keyboard, lv_obj_t* textarea) {
// Only the on-screen keyboard's show/hide wiring is specific to "no hardware keyboard"
// mode. Group membership must NOT be gated on it: a hardware keypad indev (see
// lvgl_keyboard_enable()/lvgl_software_keyboard_activate()) is bound to keyboard_group
// regardless of whether a software keyboard is in use, so skipping lv_group_add_obj()
// here left every textarea unreachable from a hardware keyboard - it was never a member
// of the group its indev delivers key events through.
if (lvgl_software_keyboard_is_enabled()) {
lv_obj_add_event_cb(textarea, textarea_show_keyboard, LV_EVENT_FOCUSED, nullptr);
lv_obj_add_event_cb(textarea, textarea_hide_keyboard, LV_EVENT_DEFOCUSED, nullptr);
lv_obj_add_event_cb(textarea, textarea_hide_keyboard, LV_EVENT_READY, nullptr);
// lv_obj_t auto-remove themselves from the group when they are destroyed (last checked in LVGL 8.3)
lv_group_add_obj(keyboard_group, textarea);
lvgl_software_keyboard_activate(keyboard);
}
// lv_obj_t auto-remove themselves from the group when they are destroyed (last checked in LVGL 8.3)
lv_group_add_obj(keyboard_group, textarea);
lvgl_software_keyboard_activate(keyboard);
}
void lvgl_software_keyboard_activate(LvglSoftwareKeyboard* keyboard) {