Menu (lv_menu)

The Menu Widget can be used to create multi-level menus that automatically handle navigation among menu levels, and enable its user to capture page navigation and click events.

Edit on GitHub

Overview

The Menu Widget can be used to create multi-level menus that automatically handle navigation among menu levels, and enable its user to capture page navigation and click events.

Parts and Styles

The Menu Widget is built from the following Widgets:

  • Main container: lv_menu_main_cont
  • Main header: lv_menu_main_header_cont
  • Back button: Button (lv_button)
  • Back button icon: Image (lv_image)
  • Main Page: lv_menu_page
  • Sidebar container: lv_menu_sidebar_cont
  • Sidebar header: lv_menu_sidebar_header_cont
  • Back button: Button (lv_button)
  • Back button icon: Image (lv_image)
  • Sidebar Page: lv_menu_page

Usage

Create a Menu

lv_menu_create(parent) creates a new empty Menu.

This creates a Menu Widget with this object hierarchy:

Note that no sidebar is created. You can create one later if you wish.

Header mode

The following header modes exist:

You can set header modes with lv_menu_set_mode_header(menu, LV_MENU_HEADER...).

Root back button mode

The following root back button modes exist:

  • LV_MENU_ROOT_BACK_BTN_DISABLED (default)
  • LV_MENU_ROOT_BACK_BTN_ENABLED

You can set root back button modes with lv_menu_set_mode_root_back_button(menu, LV_MENU_ROOT_BACK_BTN...).

Create a Menu Page

lv_menu_page_create(menu, title) creates a new empty Menu Page. You can add any Widgets to the Page.

Set a Menu Page in the main area

Once a Menu Page has been created, you can set it to the main area with lv_menu_set_page(menu, page). NULL to clear main and clear Menu history.

Set a Menu Page in the sidebar

Once a Menu Page has been created, you can set it to the sidebar with lv_menu_set_sidebar_page(menu, page). NULL to clear sidebar.

Linking between Menu Pages

If you have, for instance, created a button obj in the main Page. When you click the button Widget, you want it to open up a new Page, use lv_menu_set_load_page_event(menu, btn, new page).

Create a Menu container, section, separator

The following objects can be created so that it is easier to style the Menu:

Events

Further Reading

Learn more about Events emitted by all Widgets.

Learn more about events.

Keys

No Keys are processed by Menu Widgets.

Further Reading

Learn more about Keys.

Examples

Simple Menu

Simple Menu with root btn

Simple Menu with custom header

Simple Menu with floating btn to add new menu page

Complex Menu

API

How is this guide?

Last updated on

On this page