Callback on Object does not Work


I am trying to make a callback on a label. For now, I’d like to simply change the color to verify it works.

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


What LVGL version are you using?

v7.9 according to lv_port_esp on GitHub

What do you want to achieve?

When the screen is pressed on my label, I want the label to change colors.

What have you tried so far?

I have tried adding a call back with lv_obj_set_event_cb

Code to reproduce

	lv_obj_t* lb_sett = lv_label_create(lv_scr_act(), NULL);
	lv_obj_set_size(lb_sett, 80, 30);
	lv_obj_align(lb_sett, NULL, LV_ALIGN_IN_TOP_LEFT, 240, 35);
	lv_obj_set_event_cb(lb_sett, lb_sett_change_color);
	lv_label_set_recolor(lb_sett, true);
	lv_label_set_text(lb_sett, "#000000 sett");
static void lb_sett_change_color(lv_obj_t* obj, lv_event_t event)
//	if(event == LV_EVENT_PRESSED)
//	{
		lv_label_set_text(obj, "#45F03F sett");
//	}

i removed the condition, however, the callback still does not work.

You need to make it clickable with lv_obj_set_click. Check out the documentation on object attributes.