Phosphor::MenuMock
Inherits Phosphor::MockWidget < Reference < Object
A horizontal or vertical menu bar with named, individually selectable command items.
Generic and app-agnostic: no knowledge of AppState, Msg, or the
application theme. The Widget wrapper resolves theme → Style values
and sets them in Props before each render.
Constructors
Initialises the menu with props and an optional state.
Instance methods
Responds to navigation and selection commands.
Cmd::MoveRight,Cmd::MoveDown— advancesfocused_indexby one item, wrapping to the start, skipping over disabled items.Cmd::MoveLeft,Cmd::MoveUp— retreatsfocused_indexby one item, wrapping to the end, skipping over disabled items.Cmd::Confirm— returnsCmdResult::Bubbleif the focused item is not disabled, so the owningWidgetcan emit a domainMsg; returnsCmdResult::Noneif it's disabled or there are no items.- Any other command — returns
CmdResult::None.
Renders props.items according to props.direction.
Direction::Horizontal renders all items in a single row at
frame.y, separated by props.separator, truncated at frame.width.
Direction::Vertical renders one item per row starting at frame.y,
clipped at frame.height. Either way, each item renders as
"label [key]" when key is set or just label otherwise, using
item.style (or item.disabled_style when item.disabled), with the
focused item additionally reversed.
Narrows the inherited state getter to MenuMock::WidgetState. Safe:
initialize only ever stores a WidgetState into the base @state
ivar.