acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
menu.md (3328B)
1 ```eval_rst 2 .. include:: /header.rst 3 :github_url: |github_link_base|/widgets/extra/menu.md 4 ``` 5 # Menu (lv_menu) 6 7 ## Overview 8 The menu widget can be used to easily create multi-level menus. It handles the traversal between pages automatically. 9 10 ## Parts and Styles 11 The menu widget is built from the following objects: 12 - Main container: lv_menu_main_cont 13 - Main header: lv_menu_main_header_cont 14 - Back btn: [lv_btn](/widgets/core/btn) 15 - Back btn icon: [lv_img](/widgets/core/img) 16 - Main page: lv_menu_page 17 - Sidebar container: lv_menu_sidebar_cont 18 - Sidebar header: lv_menu_sidebar_header_cont 19 - Back btn: [lv_btn](/widgets/core/btn) 20 - Back btn icon: [lv_img](/widgets/core/img) 21 - Sidebar page: lv_menu_page 22 23 ## Usage 24 25 ### Create a menu 26 `lv_menu_create(parent)` creates a new empty menu. 27 28 ### Header mode 29 The following header modes exist: 30 - `LV_MENU_HEADER_TOP_FIXED` Header is positioned at the top. 31 - `LV_MENU_HEADER_TOP_UNFIXED` Header is positioned at the top and can be scrolled out of view. 32 - `LV_MENU_HEADER_BOTTOM_FIXED` Header is positioned at the bottom. 33 34 You can set header modes with `lv_menu_set_mode_header(menu, LV_MENU_HEADER...)`. 35 36 ### Root back button mode 37 The following root back button modes exist: 38 - `LV_MENU_ROOT_BACK_BTN_DISABLED` 39 - `LV_MENU_ROOT_BACK_BTN_ENABLED` 40 41 You can set root back button modes with `lv_menu_set_mode_root_back_btn(menu, LV_MENU_ROOT_BACK_BTN...)`. 42 43 ### Create a menu page 44 `lv_menu_page_create(menu, title)` creates a new empty menu page. 45 You can add any widgets to the page. 46 47 ### Set a menu page in the main area 48 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. 49 50 ### Set a menu page in the sidebar 51 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. 52 53 ### Linking between menu pages 54 For instance, you have created a btn obj in the main page. When you click the btn obj, you want it to open up a new page, use `lv_menu_set_load_page_event(menu, obj, new page)`. 55 56 ### Create a menu container, section, separator 57 The following objects can be created so that it is easier to style the menu: 58 59 `lv_menu_cont_create(parent page)` creates a new empty container. 60 61 `lv_menu_section_create(parent page)` creates a new empty section. 62 63 `lv_menu_separator_create(parent page)` creates a separator. 64 65 ## Events 66 - `LV_EVENT_VALUE_CHANGED` Sent when a page is shown. 67 - `lv_menu_get_cur_main_page(menu)` returns a pointer to menu page that is currently displayed in main. 68 - `lv_menu_get_cur_sidebar_page(menu)` returns a pointer to menu page that is currently displayed in sidebar. 69 - `LV_EVENT_CLICKED` Sent when a back btn in a header from either main or sidebar is clicked. `LV_OBJ_FLAG_EVENT_BUBBLE` is enabled on the buttons so you can add events to the menu itself. 70 - `lv_menu_back_btn_is_root(menu, btn)` to check if btn is root back btn 71 72 See the events of the [Base object](/widgets/obj) too. 73 74 Learn more about [Events](/overview/event). 75 76 ## Keys 77 No keys are handled by the menu widget. 78 79 Learn more about [Keys](/overview/indev). 80 81 82 ## Example 83 84 ```eval_rst 85 .. include:: ../../../examples/widgets/menu/index.rst 86 ``` 87 88 ## API 89 90 ```eval_rst 91 .. doxygenfile:: lv_menu.h 92 :project: lvgl 93 94 ```