Description
I want to navigate with an encoder in menu cont.But I found that it is unreachable.
What MCU/Processor/Board and compiler are you using?
visual studio 2019
What LVGL version are you using?
v8.1
What do you want to achieve?
navigate in menu with encoder
What have you tried so far?
test with below. it had no effect.
so test below.it had no effect.
Code to reproduce
void menu()
{
lv_obj_t* _menu = lv_menu_create(lv_scr_act());
lv_obj_t* label;
lv_obj_t* cont;
// // draw menu screen //
_menu = lv_menu_create(lv_scr_act());
lv_menu_set_mode_root_back_btn(_menu, LV_MENU_ROOT_BACK_BTN_ENABLED);
lv_obj_set_size(_menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
lv_obj_center(_menu);
char s1[] = "Page1", s2[] = "Page2";
lv_obj_t* sub_1_page = lv_menu_page_create(_menu, s1);
cont = lv_menu_cont_create(sub_1_page);
label = lv_label_create(cont);
lv_label_set_text(label, "Hello, I am hiding here on page 1");
lv_obj_t* sub_2_page = lv_menu_page_create(_menu, s2);
cont = lv_menu_cont_create(sub_2_page);
label = lv_label_create(cont);
lv_label_set_text(label, "Hello, I am hiding here on page 2");
// Create a main page
lv_obj_t* _mainPage = lv_menu_page_create(_menu, NULL);
lv_obj_t* section = lv_menu_section_create(_mainPage);
cont = lv_menu_cont_create(_mainPage);
label = lv_label_create(cont);
lv_label_set_text(label, "Item 1");
lv_menu_set_load_page_event(_menu, cont, sub_1_page);
lv_group_add_obj(lv_obj_get_group(_menu), cont);
lv_obj_add_flag(cont, LV_OBJ_FLAG_CHECKABLE);
lv_obj_add_flag(cont, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_flag(cont, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
cont = lv_menu_cont_create(_mainPage);
label = lv_label_create(cont);
lv_label_set_text(label, "Item 2");
lv_menu_set_load_page_event(_menu, cont, sub_2_page);
lv_group_add_obj(lv_obj_get_group(_menu), cont);
lv_obj_add_flag(cont, LV_OBJ_FLAG_CHECKABLE);
lv_obj_add_flag(cont, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_flag(cont, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_menu_set_sidebar_page(_menu, _mainPage);
}
Screenshot and/or video
with mousewheel. the selected box is just around with LV_MENU_ROOT_BACK_BTN,
it can not go to Item1 or Item2. I do not know how to deal with it.