The menu widget can be used to easily create multi-level menus. It handles the traversal between pages automatically.
The menu widget is built from the following objects:
- Main container: :cpp
lv_menu_main_cont
- Main header: :cpp
lv_menu_main_header_cont
- Back button:
lv_button
- Back button icon:
lv_image
- Main page: :cpp
lv_menu_page
- Sidebar container: :cpp
lv_menu_sidebar_cont
- Sidebar header: :cpp
lv_menu_sidebar_header_cont
- Back button:
lv_button
- Back button icon:
lv_image
- Sidebar page: :cpp
lv_menu_page
:cpplv_menu_create(parent)
creates a new empty menu.
The following header modes exist:
- :cpp
LV_MENU_HEADER_TOP_FIXED
Header is positioned at the top. - :cpp
LV_MENU_HEADER_TOP_UNFIXED
Header is positioned at the top and can be scrolled out of view. - :cpp
LV_MENU_HEADER_BOTTOM_FIXED
Header is positioned at the bottom.
You can set header modes with :cpplv_menu_set_mode_header(menu, LV_MENU_HEADER...)
.
The following root back button modes exist:
- :cpp
LV_MENU_ROOT_BACK_BTN_DISABLED
- :cpp
LV_MENU_ROOT_BACK_BTN_ENABLED
You can set root back button modes with :cpplv_menu_set_mode_root_back_button(menu, LV_MENU_ROOT_BACK_BTN...)
.
:cpplv_menu_page_create(menu, title)
creates a new empty menu page. You can add any widgets to the page.
Once a menu page has been created, you can set it to the main area with :cpplv_menu_set_page(menu, page)
. NULL
to clear main and clear menu history.
Once a menu page has been created, you can set it to the sidebar with :cpplv_menu_set_sidebar_page(menu, page)
. NULL
to clear sidebar.
For instance, you have created a button obj in the main page. When you click the button obj, you want it to open up a new page, use :cpplv_menu_set_load_page_event(menu, obj, new page)
.
The following objects can be created so that it is easier to style the menu:
- :cpp
lv_menu_cont_create(parent page)
creates a new empty container. - :cpp
lv_menu_section_create(parent page)
creates a new empty section. - :cpp
lv_menu_separator_create(parent page)
creates a separator.
- :cpp
LV_EVENT_VALUE_CHANGED
Sent when a page is shown.- :cpp
lv_menu_get_cur_main_page(menu)
returns a pointer to menu page that is currently displayed in main. - :cpp
lv_menu_get_cur_sidebar_page(menu)
returns a pointer to menu page that is currently displayed in sidebar.
- :cpp
- :cpp
LV_EVENT_CLICKED
Sent when a back button in a header from either main or sidebar is clicked. :cppLV_OBJ_FLAG_EVENT_BUBBLE
is enabled on the buttons so you can add events to the menu itself.- :cpp
lv_menu_back_button_is_root(menu, button)
to check if button is root back button
- :cpp
See the events of the Base object <lv_obj>
too.
Learn more about events
.
No keys are handled by the menu widget.
Learn more about indev_keys
.