Skip to main content

Module context_menu

Module context_menu 

Source
Available on crate feature context-menu only.
Expand description

A menu that opens at the pointer on a right-click inside an area, or at the finger on a long press.

It uses the dropdown menu’s entries, rows and navigation: build the entries with dropdown_menu::item and friends. State adds where the menu opened. On a touch screen, a finger held still on the area for LONG_PRESS opens it. From the keyboard, Shift+F10 or the Menu key opens it just below the area, aligned with its start, as desktop apps do.

One State can serve many areas, such as every row of a list: give each area a key with keyed, and the open events carry the key of the area they came from. State::target tells the app which row a chosen item belongs to.

Keyboard shortcuts resolve through a Keymap of Actions; see default_keymap. The open menu handles its own keys; the app routes the opening chord through State::key_event.

Structs§

ContextMenu
A context menu builder. Convert it into an Element to render.
State
The menu, which area it opened on and where.

Enums§

Action
What a context menu keyboard shortcut does.
Event
Changes to a context menu. Key names the area an open event came from; it is () for a menu with a single area.

Constants§

KEYBOARD_GAP
Gap between an area and a menu opened from the keyboard below it.
LONG_PRESS
How long a finger rests on an area before the menu opens.
LONG_PRESS_SLOP
How far, in logical pixels, a finger may drift during a long press. Any further and it counts as a scroll or a drag.

Functions§

context_menu
Makes content an area that opens the menu of state on a right-click. Without on_event right-clicks do nothing.
default_keymap
The default context menu shortcuts: the dropdown menu’s, plus
keyed
Makes content one of many areas sharing the menu of state, such as a row in a list. The menu shows on this area only while it is open on key, and the open events it sends carry key.
placement
Where the panel goes: at the right-click point, or just below the area, aligned with its start, when the menu opened from the keyboard.