Label object doesn't get event

label object doesn’t get event

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

vscode simulator

What LVGL version are you using?

#define LVGL_VERSION_MAJOR 7
#define LVGL_VERSION_MINOR 7
#define LVGL_VERSION_PATCH 2

What do you want to achieve?

according to the documantation, label object should get general events (ex., mouse click).
in my simulator run, it doesn’t get any mouse event.
I get events as expected on the button object.
What should I do to get general events on label object?

What have you tried so far?

Code to reproduce

static void my_event_handler(lv_obj_t * obj, lv_event_t event)
{
switch(event) {
case LV_EVENT_PRESSED:
printf(“Pressed\n”);
break;

}

}

top_label = lv_label_create(lv_scr_act(), NULL);
lv_obj_reset_style_list(top_label, LV_LABEL_PART_MAIN);
lv_obj_add_style(top_label, LV_LABEL_PART_MAIN, &style_gray);
lv_label_set_recolor(top_label, true);
lv_obj_set_event_cb(top_label, my_event_handler);
lv_label_set_text(top_label, "May. 19 15:09 " LV_SYMBOL_WIFI " #ff0000 " LV_SYMBOL_GPS " # " LV_SYMBOL_BATTERY_FULL );
lv_obj_align(top_label, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 7);

line1_label = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(line1_label, my_event_handler);
lv_label_set_text(line1_label, "Wait while we make sure all\nsystems are up and running");
lv_obj_align(line1_label, top_label, LV_ALIGN_IN_TOP_LEFT, 0, 40);

You have to enable click events on labels, as by default they pass events through to the object below them:

lv_obj_set_click(top_label, true);

Thank you very much.
It works as expected now, I can receive mouse events on a label object now.