Description
What MCU/Processor/Board and compiler are you using?
ESP32-S3
What LVGL version are you using?
8.4
What do you want to achieve?
Change menu Title Text after creation
What have you tried so far?
mySidebarMenu = lv_menu_page_create(myMenu, "Title");
// somewhere else
obj = lv_menu_get_sidebar_header(mySidebarMenu);
lv_label_set_text(lv_obj_get_child(obj,-1), "new title"); //not working!
How do I get the label object to change the title of a menu page
Thank you for your help.
void lv_menu_page_set_title(lv_obj_t* menu_page, const char* title){
lv_menu_page_t * page = (lv_menu_page_t *)menu_page;
page->title = (char*) lv_mem_realloc(page->title, strlen(title) + 1);
strcpy(page->title, title);
}
lv_menu_page_set_title(mySidebarMenu , "New Title");
Thank you for your help.
your solution updates the page->title
correctly but does not re-renders the screen. Only when I hop to another menu point and go back the title is rendered with the new value.
Do you have a Idea to force to render the page (or better only the header)?
tnx Chris
void lv_menu_page_set_title(lv_obj_t* menu_page, const char* title){
lv_menu_page_t * page = (lv_menu_page_t *)menu_page;
page->title = (char*) lv_mem_realloc(page->title, strlen(title) + 1);
strcpy(page->title, title);
lv_obj_invalidate(menu_page);
}
Sorry still no update of the header title.
The coordinates calculated in lv_obj_invalidate(menu_page);
seams correct.
I don’t have in circuit debugging capabilities so I can’t dig deeper.
Sorry , change to lv_event_send(…) instead.
void lv_menu_page_set_title(lv_obj_t* menu_page, const char* title){
lv_menu_page_t * page = (lv_menu_page_t *)menu_page;
page->title = (char*) lv_mem_realloc(page->title, strlen(title) + 1);
strcpy(page->title, title);
lv_event_send(menu_page, LV_EVENT_VALUE_CHANGED, 0);
}
1 Like
Great! That does the trick. Thank you.
I’m just learning lvgl. Learned a little bit more: “I have to look into the lvgl events”.