Button When working with multiple event handlers, the button ID? Do you know?
Hi,
for example:
In lv_conf.h set
typedef uint32_t lv_obj_user_data_t;
When create a button :
...
btn[indexbutton] = lv_btn_create( parent, NULL);
lv_obj_set_user_data(btn[indexbutton], idbutton);
lv_obj_set_event_cb(btn[indexbutton], event);
...
in event function
static void event(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_CLICKED) {
uint32_t id = lv_obj_get_user_data(obj);
}
}
Ciao
Walter
2 Likes
thank you~~
Another option is to keep track of your lv_obj_t *
pointers and compare them to the one you receive in the event handler.