class

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

new(props : Props, state : WidgetState = WidgetState.new)

Initialises the menu with props and an optional state.

Source

Instance methods

handle_cmd(cmd : Cmd) : CmdResult

Responds to navigation and selection commands.

  • Cmd::MoveRight, Cmd::MoveDown — advances focused_index by one item, wrapping to the start, skipping over disabled items.
  • Cmd::MoveLeft, Cmd::MoveUp — retreats focused_index by one item, wrapping to the end, skipping over disabled items.
  • Cmd::Confirm — returns CmdResult::Bubble if the focused item is not disabled, so the owning Widget can emit a domain Msg; returns CmdResult::None if it's disabled or there are no items.
  • Any other command — returns CmdResult::None.
Source
props
Source
props=(props : Props)
Source
render_content(frame : Frame, buf : Buffer) : Void

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.

Source
state

Narrows the inherited state getter to MenuMock::WidgetState. Safe: initialize only ever stores a WidgetState into the base @state ivar.

Source

Nested types