Get the id of the button in button matrix when event != LV_EVENT_VALUE_CHANGED

How to get the button id from the button matrix when event is LV_EVENT_RELEASED? The lv_btnmatrix_get_selected_btn always returns LV_BTNMATRIX_BTN_NONE. The selected id works only if the event is LV_EVENT_VALUE_CHANGED. I want to react to buttons released event and not to clicked event.

LV_EVENT_CLICKED occurs after you clicked, AND released the button.

Well it doesn’t matter, because I can’t get the button ID even from that event. The ID is only available on LV_EVENT_VALUE_CHANGED. Do I really have to save the ID from that event to be able to identify the button on other events?

Button ID is not really important. You can tell which button clicked by the button label.
1- You subscribe to LV_EVENT_VALUE_CHANGED :
lv_obj_add_event_cb(btnmatrix, btnm_event_ta_num, LV_EVENT_VALUE_CHANGED, NULL);
2- Inside the event, get the label of the pressed button:
lv_obj_t * obj = lv_event_get_target(e);
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_selected_btn(obj));
Now, txt has the label of the pressed button, so to handle button with label “7”:
if(strcmp(txt, (char*) “7” == 0) { do whatever…}
3- If you have two buttons with same label, then create two different events.

You didn’t understand what I wanted to achieve. I can only use lv_btnmatrix_get_selected_btn on LV_EVENT_VALUE_CHANGED event. What I wanted to achieve is to only act when the button is released (clicked event). LV_EVENT_VALUE_CHANGED is sent when a button is pressed/released or repeated after long press. So what I have done is, save the button ID on LV_EVENT_VALUE_CHANGED and when LV_EVENT_CLICKED is emitted I know which button was clicked. I wanted to know if there is a simpler way to do this.