How do I move the cursor to the left on character in a TextArea one line?


I need a 1 line text area to be editable by the user. Increment each of the 6 digits.

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

I’m using a STM32H7A3ZI Nucleo board with the STM32CubeIDE

What LVGL version are you using?


What do you want to achieve?

Our product has 5 buttons. Set up as ‘+’, ‘-’, “Left”, “Right”, and “Save”. I need to allow the end user to create and save a product serial number. 6 total digits with each digit can contain 0 - 9 numbers.

What have you tried so far?

The code as is will show that the Left button was pressed but the cursor disappears.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static lv_obj_t* sn_value;
char SN_buf[] = "000000";

static void event_handlerSN(lv_event_t* e2)
    lv_event_code_t code = lv_event_get_code(e2);
    lv_obj_t* obj2 = (lv_obj_t*)lv_event_get_target(e2);
    if (code == LV_EVENT_VALUE_CHANGED) {
        char buf[20];
        LV_LOG_USER("Serial_Number: %s\n", buf);

static void button_left_event_handler(lv_event_t* e)
        lv_event_code_t code = lv_event_get_code(e);
        if (code == LV_EVENT_CLICKED) {
            LV_LOG_USER("Left Button Clicked");

void lv_display_SN_value(void)
    sn_value = lv_textarea_create(lv_scr_act());
    lv_textarea_set_one_line(sn_value, true);
    lv_obj_set_size(sn_value, 155, 65);
    lv_obj_align(sn_value, LV_ALIGN_TOP_MID, 50, 125);
    lv_obj_add_event(sn_value, event_handlerSN, LV_EVENT_READY, sn_value);
    lv_obj_add_state(sn_value, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/

    static lv_style_t style_label;
    lv_style_set_text_font(&style_label, &lv_font_montserrat_30);
    lv_obj_add_style(sn_value, &style_label, LV_STATE_DEFAULT); /* fix order */
    lv_textarea_add_text(sn_value, SN_buf);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.