Insert characters to fixed length text area


I need to create time setter. I have a hardware keyboard with digits and arrows.
The text of time is like


A user can navigate though the text with arrows. Then he push the key with a digit and the character under the cursor should change.

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


What LVGL version are you using?


What do you want to achieve?

I need a text area with fixed length and ability to replace characters under cursor.

What have you tried so far?

I have tried to catch LV_EVENT_INSERT. But any manipulations to the text area lead to nothing, crash or infinite loop.

lv_ta_set_insert_replace - nothing, because lv_textarea_set_max_length is set and text is full
lv_textarea_set_text - crash
lv_textarea_del_char and lv_textarea_del_char - infinite loop

Code to reproduce

void create()
ta = lv_textarea_create(scr, nullptr);
lv_textarea_set_text(ta, "10:10:10");
lv_textarea_set_max_length(ta, 8);
lv_obj_set_event_cb(ta, event_handler);

void event_handler(lv_obj_t * obj, lv_event_t event)
	if(event == LV_EVENT_INSERT)

  1. lv_textarea_set_insert_replace needs a string as the second parameter.
  2. If it still doesn’t work, try clearing the textarea (with lv_textarea_set_text(ta, "")) before inserting the text. If it works after that we should probably change lv_textarea_set_insert_replace to work even if the textarea is full.
  1. I tried
    char* str = (char*)lv_event_get_data();
    lv_textarea_set_insert_replace(obj, str);
    But it do nothing.

  2. Clearing and replacing work. It is OK for one character box. But for others it will need string copying.
    lv_textarea_set_text(obj, “”);
    lv_textarea_set_insert_replace(obj, str);