pub type MenuItem = ContextMenuItem;Expand description
Shared menu-row type, used by both ContextMenu and (via
crate::MenuBarItem::submenu) the crate::MenuBar dropdown.
Currently a type alias to ContextMenuItem. New code should
prefer this name — it reflects that the same shape backs every
menu (right-click context menus, menu-bar dropdowns, NSMenu /
future Win32 menu installers). Existing ContextMenuItem usages
continue to compile unchanged.
Aliased Type§
pub struct MenuItem {
pub id: Option<WidgetId>,
pub label: StyledText,
pub detail: Option<StyledText>,
pub disabled: bool,
pub key_equivalent: Option<Accelerator>,
pub checked: Option<bool>,
pub submenu: Option<Vec<ContextMenuItem>>,
}Fields§
§id: Option<WidgetId>None = separator (non-interactive); Some(id) = action.
label: StyledTextLabel for the item. Ignored for separators.
detail: Option<StyledText>Optional right-aligned detail (e.g. keyboard shortcut “Ctrl+C”).
Prefer Self::key_equivalent for new code — rasterisers
will render it via render_accelerator so the format matches
the host platform (⌘S on macOS, Ctrl+S elsewhere). detail
continues to win when both are set, for back-compat.
disabled: boolWhen true, the item is rendered dimmed and click emits no event.
key_equivalent: Option<Accelerator>Structured keyboard shortcut for the item. When Some and
Self::detail is None, rasterisers render
render_accelerator(acc, platform) as the right-aligned
shortcut hint.
checked: Option<bool>Checkbox / radio state. None = item has no state; Some(true)
renders a leading ✓ and (on macOS) sets NSMenuItem.state = .on; Some(false) reserves the prefix space without filling it
so a column of items aligns visually.
Nested submenu. When Some, activating the item opens the child
menu instead of firing an action. The TUI rasteriser renders a ▶
affordance and a pull-right popup (see
[crate::tui::draw_context_menu_with_submenus]). The macOS NSMenu
installer wires this as a real nested NSMenu. GTK is a follow-up.