From dd27c3530432ea0b09f01e604bf577f31d8ef841 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 1 Jun 2023 15:41:47 +1000 Subject: convert lvgl from submodule to a plain old directory --- lib/lvgl | 1 - lib/lvgl/examples/widgets/keyboard/index.rst | 7 ++++ .../widgets/keyboard/lv_example_keyboard_1.c | 40 ++++++++++++++++++++++ .../widgets/keyboard/lv_example_keyboard_1.py | 28 +++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) delete mode 160000 lib/lvgl create mode 100644 lib/lvgl/examples/widgets/keyboard/index.rst create mode 100644 lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.c create mode 100644 lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.py (limited to 'lib/lvgl/examples/widgets/keyboard') diff --git a/lib/lvgl b/lib/lvgl deleted file mode 160000 index 0732400e..00000000 --- a/lib/lvgl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0732400e7b564dd0e7dc4a924619d8e19c5b23a0 diff --git a/lib/lvgl/examples/widgets/keyboard/index.rst b/lib/lvgl/examples/widgets/keyboard/index.rst new file mode 100644 index 00000000..7c54e052 --- /dev/null +++ b/lib/lvgl/examples/widgets/keyboard/index.rst @@ -0,0 +1,7 @@ + +Keyboard with text area +""""""""""""""""""""""" + +.. lv_example:: widgets/keyboard/lv_example_keyboard_1 + :language: c + diff --git a/lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.c b/lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.c new file mode 100644 index 00000000..710098fe --- /dev/null +++ b/lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.c @@ -0,0 +1,40 @@ +#include "../../lv_examples.h" +#if LV_USE_KEYBOARD && LV_BUILD_EXAMPLES + +static void ta_event_cb(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * ta = lv_event_get_target(e); + lv_obj_t * kb = lv_event_get_user_data(e); + if(code == LV_EVENT_FOCUSED) { + lv_keyboard_set_textarea(kb, ta); + lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN); + } + + if(code == LV_EVENT_DEFOCUSED) { + lv_keyboard_set_textarea(kb, NULL); + lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); + } +} + +void lv_example_keyboard_1(void) +{ + /*Create a keyboard to use it with an of the text areas*/ + lv_obj_t * kb = lv_keyboard_create(lv_scr_act()); + + /*Create a text area. The keyboard will write here*/ + lv_obj_t * ta; + ta = lv_textarea_create(lv_scr_act()); + lv_obj_align(ta, LV_ALIGN_TOP_LEFT, 10, 10); + lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb); + lv_textarea_set_placeholder_text(ta, "Hello"); + lv_obj_set_size(ta, 140, 80); + + ta = lv_textarea_create(lv_scr_act()); + lv_obj_align(ta, LV_ALIGN_TOP_RIGHT, -10, 10); + lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb); + lv_obj_set_size(ta, 140, 80); + + lv_keyboard_set_textarea(kb, ta); +} +#endif diff --git a/lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.py b/lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.py new file mode 100644 index 00000000..7b7591f7 --- /dev/null +++ b/lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.py @@ -0,0 +1,28 @@ +def ta_event_cb(e,kb): + code = e.get_code() + ta = e.get_target() + if code == lv.EVENT.FOCUSED: + kb.set_textarea(ta) + kb.clear_flag(lv.obj.FLAG.HIDDEN) + + if code == lv.EVENT.DEFOCUSED: + kb.set_textarea(None) + kb.add_flag(lv.obj.FLAG.HIDDEN) + +# Create a keyboard to use it with one of the text areas +kb = lv.keyboard(lv.scr_act()) + +# Create a text area. The keyboard will write here +ta = lv.textarea(lv.scr_act()) +ta.set_width(200) +ta.align(lv.ALIGN.TOP_LEFT, 10, 10) +ta.add_event_cb(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None) +ta.set_placeholder_text("Hello") + +ta = lv.textarea(lv.scr_act()) +ta.set_width(200) +ta.align(lv.ALIGN.TOP_RIGHT, -10, 10) +ta.add_event_cb(lambda e: ta_event_cb(e,kb), lv.EVENT.ALL, None) + +kb.set_textarea(ta) + -- cgit v1.2.3