Documentation Index
Fetch the complete documentation index at: https://mintlify.com/The-Young-Maker/OpenMenuOS/llms.txt
Use this file to discover all available pages before exploring further.
MenuScreen renders a vertically scrollable list of selectable items. Each item can link to another Screen, execute a callback function, display an icon image, or any combination of the three. Menus resize automatically to the display dimensions and support unlimited nesting depth.
Constructors
MenuScreen()
Creates a menu screen without a title.
MenuScreen(const char* title)
Creates a menu screen with the given title, displayed in the header bar.
Title string shown at the top of the screen.
Item management
addItem(const char* label, Screen* nextScreen, ActionCallback action, const uint16_t* image)
Adds an item to the menu with an explicit label. All parameters after label are optional.
Display text shown for the menu item.
Screen to push onto the navigation stack when the item is selected. Pass
nullptr if no navigation is needed.Function pointer (
void (*)()) called when the item is selected. Runs before navigating to nextScreen if both are provided.Pointer to a raw RGB565 image array displayed as an icon beside the label.
addItem(Screen* nextScreen, ActionCallback action, const uint16_t* image)
Adds an item whose label is automatically taken from nextScreen->getTitle(). Useful for keeping item labels and screen titles in sync without duplicating strings.
Target screen. Its title is used as the item label.
Optional callback executed on selection.
Optional icon image pointer.
clearItems()
Removes all items from the menu. Use this to rebuild a menu dynamically at runtime.
getIndex()
Returns the zero-based index of the currently highlighted item.
Returns: int
Public properties
These members are publicly accessible on everyMenuScreen instance.
| Member | Type | Description |
|---|---|---|
title | const char* | Title string passed to the constructor. |
items | std::vector<MenuItem> | Ordered collection of all added items. |
currentItemIndex | int | Zero-based index of the currently selected item. |
itemSize | int | Total number of items in the menu. |
MenuItem struct
Each entry in items is a MenuItem with the following fields:
| Field | Type | Description |
|---|---|---|
label | const char* | Display text for the item. |
nextScreen | Screen* | Screen navigated to on selection, or nullptr. |
action | ActionCallback | Callback function invoked on selection, or nullptr. |
image | const uint16_t* | RGB565 icon image pointer, or nullptr. |
Complete example
The following sketch builds a two-level menu with action callbacks and an icon.Items added with
addItem(Screen* nextScreen) automatically reflect any change to the target screen’s title — you do not need to update the label string separately.