Lvgl: [Question] How to use free_num with the buttons on a Message box?

Created on 17 Nov 2018  路  4Comments  路  Source: lvgl/lvgl

Hello,

I use multilanguage GUI, and I can't rely on button's text to identify the button being pressed, as it can have multiple different values based on the GUI language used.

What is the proper way to use lv_obj_set_free_num on the buttons on a message box, and then use that in the click action callback?

Thanks!

All 4 comments

@mharizanov lv_obj_set_free_num doesn't work on button matrices (which lv_mbox uses) because they are not really composed of multiple buttons. However, I read the area of lv_btnm.c that deals with button click handling, and this might work inside the lv_mbox callback action (untested):

lv_btnm_ext_t *btnm_ext = lv_obj_get_ext_attr(btnm);
if(btnm_ext->btn_id_pr == 0) { } /* First button */
else if(btnm_ext->btn_id_pr == 1) { } /* Second button */

@kisvegabor If it works I think this would be a good API to add.

Yes, that worked. Thanks! I think an API call makes sense for use cases like mine.

I agree it'd be really useful.
I added the API extension here: #563 Please have a look at it.

Thanks Gabor, you rock!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IronCaterpillar picture IronCaterpillar  路  4Comments

ashrafkamel5 picture ashrafkamel5  路  5Comments

curly-brace picture curly-brace  路  5Comments

DeonMarais64 picture DeonMarais64  路  4Comments

relliktei picture relliktei  路  4Comments