Yes the lv_event_get_user_data() is used in simple event to get the user data,
the problem here is I don’t know how to make differences between user_data in event handling multiple user_data,
i gaved the example of button matrix, every button state checked need to be linked to page (like the tabview but with possibility to hide all page and have all buttons unchecked),
button matrix event in case of button is change_value would make this :
- make one check button or uncheck all buttons
- display objects related to button ID checked.
- hide other objects related to other buttons unchecked
in case of button matrix i assume that we can’t apply event to every button individualy (they are virtual buttons) and there is no function to access to each button separatly,
I tried to apply lv_obj_get_child(btnm,1) where i add event but my application is crashing, see bellow
static void btnmatrix_my_cb(lv_event_t * e ) {
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * obj = lv_event_get_target(e);
lv_obj_t *user =lv_event_get_user_data(e);
if(code == LV_EVENT_VALUE_CHANGED) {
lv_state_t stat = lv_obj_get_state(obj);
if(stat == LV_STATE_CHECKED) lv_obj_clear_flag(user,LV_OBJ_FLAG_HIDDEN);
else lv_obj_add_flag(user,LV_OBJ_FLAG_HIDDEN);
}
}
.
.
lv_obj_add_event_cb(lv_obj_get_child(btnm,2),btnmatrix_my_cb,LV_EVENT_VALUE_CHANGED,num1);
lv_obj_add_event_cb(lv_obj_get_child(btnm,2),btnmatrix_my_cb,LV_EVENT_VALUE_CHANGED,num2)
And i don’t know how to handle multiple users in one event_callback because the event_callback is called every event on target, and i can’t see how to make differences between users,
Maybe be i took a button matrix which is a little bit difficult to begin, but i’m sure there’s a way that i can’t see to make it work,
I don’t know if there is a way to link object states to other’s (the group option i didn’t get it well yet)
@pete-pjb, please, Can you take a look at this ?
Kind regards,
Zebra