2021-04-08 13:07:48 +02:00
|
|
|
#include "../../lv_examples.h"
|
2021-02-14 14:56:34 +01:00
|
|
|
#if LV_USE_KEYBOARD && LV_BUILD_EXAMPLES
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
static void ta_event_cb(lv_obj_t * ta, lv_event_t e)
|
|
|
|
{
|
|
|
|
lv_obj_t * kb = lv_event_get_user_data();
|
|
|
|
if(e == LV_EVENT_FOCUSED) {
|
|
|
|
lv_keyboard_set_textarea(kb, ta);
|
|
|
|
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(e == LV_EVENT_DEFOCUSED) {
|
|
|
|
lv_keyboard_set_textarea(kb, NULL);
|
|
|
|
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-19 18:19:32 +01:00
|
|
|
void lv_example_keyboard_1(void)
|
2021-02-08 09:53:03 +01:00
|
|
|
{
|
|
|
|
/*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;
|
2021-03-25 13:36:50 +01:00
|
|
|
ta = lv_textarea_create(lv_scr_act());
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_align(ta, LV_ALIGN_TOP_LEFT, 10, 10);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_obj_add_event_cb(ta, ta_event_cb, kb);
|
|
|
|
lv_textarea_set_placeholder_text(ta, "Hello");
|
|
|
|
|
2021-03-25 13:36:50 +01:00
|
|
|
ta = lv_textarea_create(lv_scr_act());
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_align(ta, LV_ALIGN_TOP_RIGHT, -10, 10);
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_obj_add_event_cb(ta, ta_event_cb, kb);
|
|
|
|
|
|
|
|
lv_keyboard_set_textarea(kb, ta);
|
|
|
|
}
|
|
|
|
#endif
|