ContextMenu
Overlays · interactive
A menu, and the same menu at a point rather than under a control.
Import
cpp
#include "gbui/widgets/contextMenu.hpp"Example
ContextMenu
contextMenu · Overlays · interactive
Nothing is downloaded until you press it.
cpp
MenuResult contextMenu(Ui& ui, const Interaction& input, std::string_view id, Vec2 at, const std::vector<MenuEntry>& entries, MenuState& state, const MenuOptions& options = {});The same menu, at a point. at is where the pointer was when the reader asked for it — keep it, because a menu that re-reads the live pointer position walks away from itself as the reader moves towards it. if (input.rightClicked("row")) { menuAt = input.pointer(); menuOpen = true; } if (menuOpen)
Menu
menu · Overlays · interactive
Nothing is downloaded until you press it.
cpp
MenuResult menu(Ui& ui, const Interaction& input, std::string_view id, std::string_view anchorId, const std::vector<MenuEntry>& entries, MenuState& state, const MenuOptions& options = {});A menu hanging off anchorId. Draw it while the caller's own flag says it is open, exactly as popover is drawn — this holds no open state of its own.
API
MenuOptions
| Option | Type | Default | What it does |
|---|---|---|---|
name | std::string_view | What the menu is, announced before its first row. | |
width | float | 0.0f | How wide it is. Zero sizes it to its widest row, which is what a menu should do — a fixed width either truncates a command or leaves a gap. |
maxVisible | std::size_t | 14 | How many rows before it scrolls. |
MenuOptions
| Option | Type | Default | What it does |
|---|---|---|---|
name | std::string_view | What the menu is, announced before its first row. | |
width | float | 0.0f | How wide it is. Zero sizes it to its widest row, which is what a menu should do — a fixed width either truncates a command or leaves a gap. |
maxVisible | std::size_t | 14 | How many rows before it scrolls. |