ContextMenu opens a menu when the user long-presses its children. The menu opens at the press point, with its top-left corner under the finger by default. Near an edge of the screen it opens on the other side of the point. It uses the same menu as DropdownWrapper: pressing outside it or the back button closes it. See the web ContextMenu page for the web version.
Wrap the element and pass the menu's content, usually Options. Pressing an option calls onSelect with its value and closes the menu.
A pressable child, such as a Button, keeps its own onPress for a short press. A long press opens the menu after the child's own onLongPress.
Pass open and onOpenChange to control the menu. disabled ignores long presses and dims the children.
- A long press opens the menu, in place of a right-click or Control-click. A screen reader's long press has no point, so the menu opens under the children, as the web does for a menu opened from the keyboard. There is no haptic feedback.
- The long press reaches a pressable child through its onLongPress. A child that is pressable but does not pass onLongPress on to its Pressable does not open the menu. With several children, the long press is only caught outside pressable ones.
- onSelect, selectedOption and closeAfterClick reach the Options written in dropdown, as in DropdownWrapper.
- There is no contents mode or className, and no arrow-key navigation. The region around the children sits at its content's width unless fillWidth is set.