From 9c54ac4944a1bb3e849d1eb38218e14b98217e21 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sat, 8 Aug 2026 23:46:52 +0200 Subject: [PATCH] Fix for keyboard --- .../lvgl-module/include/lvgl/devices/keyboard.h | 9 ++++----- Modules/lvgl-module/source/devices/keyboard.cpp | 16 +++++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Modules/lvgl-module/include/lvgl/devices/keyboard.h b/Modules/lvgl-module/include/lvgl/devices/keyboard.h index e64776763..d0c0af61e 100644 --- a/Modules/lvgl-module/include/lvgl/devices/keyboard.h +++ b/Modules/lvgl-module/include/lvgl/devices/keyboard.h @@ -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 diff --git a/Modules/lvgl-module/source/devices/keyboard.cpp b/Modules/lvgl-module/source/devices/keyboard.cpp index 24ad2d29d..bdc08780a 100644 --- a/Modules/lvgl-module/source/devices/keyboard.cpp +++ b/Modules/lvgl-module/source/devices/keyboard.cpp @@ -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) {