Trying to simulate a 'Clicked' event on a textarea to focus


I am trying to simulate a press on a textarea without actually pressing the textarea.
Currently I have a button that, when pressed, shows the keyboard and textarea however the LV_EVENT_DEFOCUSED will not work since the textarea has not been pressed.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

Trick the program into thinking the textarea is focused so the LV_EVENT_DEFOCUSED event can trigger in the ta_event_cb

What have you tried so far?

lv_obj_add_state(ta, LV_STATE_FOCUSED);

This sets focus to the text area which is nice however It does not allow the defocus to trigger when pressing off of the textarea.

I have tried this:

lv_event_send(ta, LV_EVENT_CLICKED, NULL);

Which seems to crash the code.

lv_event_send(ta, LV_EVENT_FOCUSED, NULL);

This compiles but does not do what I would like

Maybe it helps to

lv_obj_add_state(ta, LV_STATE_FOCUSED);

lv_textarea_set_cursor_pos(ta, 0);

Unfortunately this still does not simulate the Focused Event on the textarea.

I am still unable to figure out how to resolve this problem.

I have resolved this by adding the following to ‘my_touchpad_read()’ :

if(!(lv_obj_has_flag(kb, LV_OBJ_FLAG_HIDDEN)) && data->point.y < 80)