Why is this an error: "lv_obj_t* ta = lv_event_get_target(e);"

Description

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

Windows simulator

What LVGL version are you using?

V8

What do you want to achieve?

Get the simulator to run

What have you tried so far?


static void event_handlerSN(lv_event_t* e)
{
    lv_obj_t* ta = lv_event_get_target(e); <--------------- This line is the error
    const char* txt = lv_textarea_get_text(ta);
    LV_LOG_USER("Serial_Number: %s\n", txt);
}

The error message is: “a value of type void * cannot be used to initialize an entity of type lv_obj_t *”

What can I do to fix this?

Try changing the line to:

lv_obj_t * ta = (lv_obj_t *)lv_event_get_target(e);

Hope that helps

1 Like