Phosphor::PopupMenuMock
Inherits Phosphor::MockWidget < Reference < Object
A floating context menu that appears at a specific absolute position,
rendered as an overlay last in Screen#render, sized to its content.
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.
Distinct from ConfirmMock (list of actions, not a yes/no question) and
ListMock (positional, floating, transient rather than filling a
layout slot). Unlike every other MockWidget, PopupMenuMock ignores
the frame it's given for positioning — it places itself at
props.origin_x/props.origin_y instead, using the frame only to size
and clip itself so it never writes off-screen.
Constructors
Initialises the popup with props and an optional state.
Instance methods
Responds to navigation, confirm, and cancel commands.
Cmd::MoveDown— advancesstate.focused_indexby one item, wrapping to the start, skipping over disabled items.Cmd::MoveUp— retreatsstate.focused_indexby one item, wrapping to the end, skipping over disabled items.Cmd::Confirm—CmdResult::Bubbleif the focused item isn't disabled, so the owningWidgetcan emit a domainMsg;CmdResult::Noneif it's disabled or there are no items.Cmd::Cancel— alwaysCmdResult::Bubble, regardless of the focused item, so the owningWidgetcan dismiss the popup.- Any other command — returns
CmdResult::None.
Draws a bordered box of items at props.origin_x/props.origin_y,
sized to content and clipped to frame.
Width is the longest item label plus 2 cells (the border's left and
right edges), capped at frame.width; height is props.items.size
plus 2 (top and bottom border rows), capped at frame.height. The
popup's actual top-left corner is props.origin_x/props.origin_y
shifted inward just enough to keep the whole box within frame —
never partially off-screen when there's room to avoid it. Drawing
itself (border + items) delegates to BorderMock wrapping an
internal item-list widget, the same composition ConfirmMock uses.
Narrows the inherited state getter to PopupMenuMock::WidgetState.
Safe: initialize only ever stores a WidgetState into the base
@state ivar.