Navigation in OpenMenuOS is stack-based. Every time the user moves forward to a new screen, the previous screen is pushed onto a history stack so it can be restored when the user goes back. This model supports menus of unlimited depth and requires no manual bookkeeping on your part — the library manages the stack automatically as the user interacts with items.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.
How the history stack works
ScreenManager maintains a std::vector<Screen*> called screenHistory. When a new screen becomes active:
- The current screen is appended to
screenHistory. - The new screen becomes
currentScreenand itsdraw()method is called immediately. - The global
::currentScreenpointer is updated to match.
screenHistory is popped off and restored as the active screen.
getDepth() returns the current number of entries.
Linking screens via addItem()
The most common way to connect screens is through MenuScreen::addItem(). When the user selects an item that has a nextScreen pointer, the library calls pushScreen() automatically.
addItem(Screen*) — reads getTitle() from the target screen and uses it as the list label, keeping titles consistent without repetition.
Programmatic navigation
Two methods onOpenMenuOS let you navigate from code, for example inside action callbacks or a CustomScreen.
ScreenManager::pushScreen() and ScreenManager::popScreen() and update the global currentScreen variable.
Calling
redirectToScreen() from a callback still respects the stack — the user can press the select button long-press or any “back” gesture to return to the calling screen.The global currentScreen variable
OpenMenuOS exposes a global pointer:
redirectToScreen() and navigateBack() rather than assigning to it directly.
Navigation flow step by step
Create your screens
Declare each screen at global scope (or as long-lived objects) so their pointers remain valid for the lifetime of the program.
Link screens together
Use
addItem() to wire screens into a hierarchy. Items without a nextScreen can still execute a callback or have no action.Set the root screen and start
Pass the root screen to
begin(). This screen is the bottom of the history stack and cannot be popped.Navigate programmatically when needed
Use
redirectToScreen() inside callbacks for non-linear flows, such as jumping to a confirmation screen or a context-specific sub-page.pushScreen and popScreen behavior
| Method | Effect | Returns |
|---|---|---|
pushScreen(screen) | Saves current screen to history, activates screen | void |
popScreen() | Restores previous screen from history | true on success, false if already at root |
canGoBack() | Checks whether history is non-empty | bool |
getDepth() | Returns the number of screens in history | size_t |