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§
- Context
Menu - A context menu builder. Convert it into an
Elementto 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.
Keynames 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
contentan area that opens the menu ofstateon a right-click. Withouton_eventright-clicks do nothing. - default_
keymap - The default context menu shortcuts: the dropdown menu’s, plus
- keyed
- Makes
contentone of many areas sharing the menu ofstate, such as a row in a list. The menu shows on this area only while it is open onkey, and the open events it sends carrykey. - 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.