Skip to content

Menu

Overlays · interactive

The rows inside a popover.

Import

cpp
#include "gbui/widgets/menu.hpp"

Example

menuItem · Overlays · interactive

Nothing is downloaded until you press it.

cpp
bool menuItem(Ui& ui, const Interaction& input, std::string_view id, std::string_view label, const MenuItemOptions& options = {});

Returns true on the frame it was chosen.

menuSeparator · Overlays

Nothing is downloaded until you press it.

cpp
void menuSeparator(Ui& ui);

A rule between groups of items.

API

OptionTypeDefaultWhat it does
leading optionalstd::optional<Icon>
shortcutstd::string_viewDrawn right-aligned in the mono face, and drawn only: the row does not bind it. A menu is where a shortcut is advertised; the application is where it is handled.
selectedboolfalseThe chosen value: a check mark and the strong text colour.
checkSideCheckSide
Leading · Trailing
CheckSide::LeadingWhere that check mark goes. Leading suits a menu, trailing a select.
highlightedboolfalseDrawn as though the pointer were on it. That is what walking a list with the arrow keys looks like — the highlight moves and the pointer does not — and it is a different question from selected, which is the value the list would return.
disabledboolfalse
dangerboolfalseThe destructive one, in the error colour — which is the only warning a reader gets before pressing it.
focusablebooltrueWhether Tab can land on it. A list whose owner drives the highlight — a select — turns this off, so Tab leaves the control instead of walking into an open popup and back out of the window's order.
roleRoleRole::MenuItemWhat a reader is told this row is. The same distinction checkSide draws visually, and it has to be said separately because a screen reader announces the two differently: a menu holds commands — "New branch, menu item" — and a select holds values, where the reader also wants "option, three of twelve". A command that toggles is MenuItemCheckbox, which is what makes selected announce "not checked" instead of saying nothing.
positionInSetstd::size_t0Its place in the list, one-based, and how long the list is. Zero on both is "not one of a set", which is right for a menu: a reader walking commands does not want them counted. A select sets them, and a filtered select sets them from what is shown — "3 of 40" in a list narrowed to four is three lies in five words.
setSizestd::size_t0

Released under the LGPL-3.0-or-later licence.