Skip to main content

Module menu

Module menu 

Source
Expand description

Item — a row in a dropped menu — and card, the panel that paints a list of them plus the panels its Item::Submenu rows drop.

Every menu in the system is those two over the caller’s own open state: the bar’s dropped panel (crate::menubar), the ··· on a row, the picker under a chip. The state stays with the caller because only it knows what opening means — a crate::popover::Popup for one, a field for another.

Cursor is the one piece of state the card asks for: which submenus are down and which row is live. Pointer and keyboard both move it, so the two can never disagree about which row an open submenu hangs off. What the pointer did comes back as a Hit; acting on it stays the caller’s.

Structs§

Confirm
Cursor
Where an open menu is being worked: open is the chain of submenu rows currently down, outermost first, row is the live row in the menu that chain ends at, and segment the live segment when that row is an Item::Segmented.
Dismiss
MenuIndent
How far each Item::indented level moves a row’s content in, app-wide.
MenuWidth
How wide a menu’s panels sit, app-wide.
Segment
One option of an Item::Segmented row.
SelectChild
SelectNext
SelectParent
SelectPrevious

Enums§

Described
How a panel holding a described row is sized. A description is one line, cut at the panel’s edge.
Edit
A row of a text surface’s right-click menu, in the order edit_items lists them.
Hit
What the pointer did to a menu. Every variant is a request: the caller’s Cursor and open state are what answer it.
Item
A row in a menu.

Constants§

SEARCH_CONTEXT
The key context around a searchable submenu’s query field. Typing goes to the field; the arrows, enter and escape fall through to the menu.

Functions§

at
The item path names — one row index per level, outermost first. None for a path to a segment of an Item::Segmented row; its path less the last index names the row.
bindings
The keymap a searchable submenu and a crate::context_menu answer to, as data — see crate::keys.
card
The panel a menu drops: every Item as a row, in a popover::popover_card, with a further panel hanging off each submenu row the Cursor holds open. id prefixes the rows’ element ids, so two menus open at once keep their hover state apart. In a test build each action and submenu row answers to the debug selector {id}/{label}.
edit_items
The rows of a text surface’s right-click menu. actions are the surface’s own Cut, Copy, Paste and Select All, read for the chord each row prints.
glyph_slot
The leading column: the row’s glyph, or the room one would have taken, so a menu of mixed rows keeps its labels on one edge.
init
Install bindings. Call once at startup.
items_at
The menu path opens into: items itself for an empty path, else the rows of the submenu each index names. None as soon as one of them does not name an open-able submenu.
next_selectable
The next row the keyboard can land on, delta deciding the direction: separators and disabled rows are stepped straight over, and both ends wrap. from of None enters the menu at the edge the direction comes from.