When button is clicked:
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * btn = lv_event_get_target(e);
if(code == LV_EVENT_CLICKED) {
lv_label_set_text(lv_label_create(btn), “Clicked !”);
}
But, it did not delete the original text. It wrote over it !!!
I also, tried to recreate style, and add it to the button, but got same behavior.
I tried to write NULL text, to maybe clear the original text, then tried to write the new text as follows:
lv_label_set_text(lv_label_create(btn), NULL);
lv_label_set_text(lv_label_create(btn), “Clicked !”);
But, this trick did not work.
Thanks.
Thanks for the code.
The lv_label_set_text(…) works. It does write the text, but the problem it writes it on top of the existing label.
Maybe I need to call another method to clear the existing text before writing new text ??
Or maybe the version I am using (8.0.2) has bug
I am not sure, because I am new to lvgl but if that is working on your system, then it must be the second possibility.
embeddededt:
You got it.
Yes, I was actually creating new label object in each case.
I just replaced it with just one as static, and it is now working properly.
Thank you very much.