Imgbtn- how to change image icon on button press

Hi,
I am using ESP32-S3 microcontroller and using LVGL version 8.3.6. I am successfully able to add image to image button and generate events like pressed/released etc. I need 5 image buttons. My requirement is like if any of the 5 image button is pressed, other image button image should also change to different image. Its like if i select any button, other buttons should image should change to non-selected.
I have tried to change the image of button using lv_imgbtn_set_src() function but for this, i am not able to find an event which i can select for setting other button image i.e. i am trying to change the image of button2,3,4,5 in the call back event of button1 press. But since there is no any event generated for button2,3,4,5 on button1 press, button1 image is not getting updated. Can any one please help me on this?
Regards
Narendra Singh

Hi,

Are all of the buttons sharing the same event handler? If not, then in handler of button 1 you can change buttons 2, 3, 4 and 5. In event handler of button 2 you can change buttons 1, 3, 4, 5 and so forth.

If all of them share the same event handler then I think you can use lv_event_get_current_target, this way you will get a pointer to the button where the event was triggered, you will need to do your button lv_obj_t global variables for this to work. See Events — LVGL documentation

Hi Carlos,
I have different event handler for each button.
I have tried the same way. but it doesn’t work as expected.
If i press button1 for example, non of the events LV_IMGBTN_STATE_RELEASED/LV_IMGBTN_STATE_PRESSED/LV_IMGBTN_STATE_DISABLED/ LV_IMGBTN_STATE_CHECKED_RELEASED/LV_IMGBTN_STATE_CHECKED_PRESSED/ LV_IMGBTN_STATE_CHECKED_DISABLED satisfy for other buttons since other buttons have not been pressed/released when button1 was pressed alone etc. So how will lv_imgbtn_set_src() set image for other buttons?
Regards
Narendra Singh

Hi Carlos,
I have been able to execute as per my need.