diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
| commit | dd27c3530432ea0b09f01e604bf577f31d8ef841 (patch) | |
| tree | bbf86cf81a78f0ff0b07f31f1c390db473f26fd3 /lib/lvgl/examples/widgets/keyboard | |
| parent | 6fd588e970470b15936187980829916d0dbe77bb (diff) | |
| download | tangara-fw-dd27c3530432ea0b09f01e604bf577f31d8ef841.tar.gz | |
convert lvgl from submodule to a plain old directory
Diffstat (limited to 'lib/lvgl/examples/widgets/keyboard')
| m--------- | lib/lvgl | 0 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/keyboard/index.rst | 7 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.c | 40 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/keyboard/lv_example_keyboard_1.py | 28 |
4 files changed, 75 insertions, 0 deletions
diff --git a/lib/lvgl b/lib/lvgl deleted file mode 160000 -Subproject 0732400e7b564dd0e7dc4a924619d8e19c5b23a 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) + |
