Skip to content

Menu

MenuHandle presents structured menu entries from a view anchor or explicit point.

auto menu = UseMenu();
IconButton(images::more, "More actions")
.With(menu.Anchor())
.OnClick([menu] {
menu.Show({
MenuItem(images::edit, "Edit", Edit),
MenuItem("Move to", {
MenuItem("Archive", Archive),
MenuItem("Favorites", AddToFavorites),
}),
MenuSection{},
MenuItem("Delete", Delete),
});
})

Leaf items contain a callback; parent items contain std::vector<MenuEntry> children. Icons may be ImageResource or ImageAsset. .Enabled(bool) and .Checked(bool) add state without changing entry structure. MenuSection marks a logical boundary; the active theme decides whether and how to draw separators.

Natural width follows the widest entry subject to theme and viewport limits. Set MenuOptions::width only when the application requires a fixed width. MenuStyle owns item padding and height, foreground, indication, separators, surface, shadow, and motion.

An open menu publishes a modal Menu collection and semantic MenuItem children. Checked, disabled, and expanded submenu state is exposed to assistive technology, and compatible entries provide activate or expand actions.

  • UseMenu() -> MenuHandle; Anchor() -> LayerAnchor.
  • Show(std::vector<MenuEntry>, MenuOptions = {}) and ShowAt(Point, ...).
  • MenuItem(label, callback) and icon overloads.
  • MenuItem(label, children) and icon overloads for submenus.
  • Enabled(bool) and Checked(bool).
  • MenuEntry, MenuSection, MenuOptions, MenuStyle, and MenuSeparatorMode.

See Popup for arbitrary anchored content.