Skip to main content

Module context_menu

Module context_menu 

Expand description

ContextMenu primitive — a right-click / long-press invoked list of actions with optional separators. Standalone owners draw it in their overlay pass. open_anchored opts into measured, viewport-bounded geometry; legacy open_at callers retain their point placement and fixed rows.

Callers push MenuItem::action(label, fn) and optional MenuItem::separator() entries, then call open_at on right-click. A menu the context-menu gesture opened takes typing (query).

Structs§

ContextMenu
EmojiRow
A row of emoji to pick one from.
MenuButton
A button that opens a menu anchored to its own rect (crate::widget::Button::with_menu): a header’s More button, a toolbar’s sort menu. The menu opens under the button, lines up with whichever of its edges keeps it in the window, and flips above near the bottom; Enter, Space or a click opens it, and the button reads as expanded while it is open.
MenuButtonProps
A button that opens a menu of commands under it: a header’s More button, a sort menu.
MenuItemProps
One command of a menu: what it shows, and what choosing it does.

Enums§

MenuItem
Separators are purely visual and ignored by ContextMenu::click_item.
MenuPick
What a row of a folded menu (MenuItem::fold_numbered) stands for: the command whose index the row was given, or the indices of the run of commands a group row opens, in the order the person meets them.

Functions§

note_input
Observe event before its window dispatches it, so a menu it opens knows whether it is a context menu: one opened by a secondary click, the Menu key or Shift+F10, rather than by a button. For window hosts.
note_shift
Say the person holds Shift, or not, as a window’s modifier change does: for a host that learns it otherwise, and for tests.
shift_held
Whether the person holds Shift right now, as the window’s last modifier change said. Shift is how a person skips a confirmation that Undo makes unnecessary: a menu row that asks first runs at once, and the host’s question is not asked (see action_palette).
shift_skips_confirmation
The one rule of every confirmation a person is asked: Shift skips it, if and only if Undo takes the action back (can_be_undone, from the action’s contract). What Undo cannot take back is asked, Shift or not.

Type Aliases§

MenuAction
What a menu row runs. Menus live on the UI thread with the widgets that open them, so a row takes the toolkit’s usual single-threaded callback: it may capture Rc state like any Button::on_click.