fix(example) add textarea event to lv_example_textarea_1

related to https://github.com/lvgl/lvgl/issues/2248
This commit is contained in:
Gabor Kiss-Vamosi
2021-05-11 13:13:01 +02:00
parent a46f20de91
commit 71fd3e68a2

View File

@@ -1,6 +1,11 @@
#include "../../lv_examples.h" #include "../../lv_examples.h"
#if LV_USE_TEXTAREA && LV_BUILD_EXAMPLES #if LV_USE_TEXTAREA && LV_BUILD_EXAMPLES
static void textarea_event_handler(lv_event_t * e)
{
lv_obj_t * ta = lv_event_get_target(e);
LV_LOG_USER("Enter was pressed. The current text is: %s", lv_textarea_get_text(ta));
}
static void btnm_event_handler(lv_event_t * e) static void btnm_event_handler(lv_event_t * e)
{ {
@@ -19,6 +24,7 @@ void lv_example_textarea_1(void)
lv_obj_t * ta = lv_textarea_create(lv_scr_act()); lv_obj_t * ta = lv_textarea_create(lv_scr_act());
lv_textarea_set_one_line(ta, true); lv_textarea_set_one_line(ta, true);
lv_obj_align(ta, LV_ALIGN_TOP_MID, 0, 10); lv_obj_align(ta, LV_ALIGN_TOP_MID, 0, 10);
lv_obj_add_event_cb(ta, textarea_event_handler, LV_EVENT_READY, ta);
lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/ lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/
static const char * btnm_map[] = {"1", "2", "3", "\n", static const char * btnm_map[] = {"1", "2", "3", "\n",