NIB / DOCUMENTATION
Context menu — NibComponents
Offer pointer and keyboard access to grouped actions, disabled entries, and nested choices.
Open interactive viewBuild a menu from entries
NibMenuEntry is the common model. NibMenuItem is selectable, NibMenuSection supplies a group label, and NibMenuDivider separates groups. They are models rather than standalone rendered buttons. Supply them to NibContextMenu or showNibContextMenu.
The demo groups reading-list actions, can disable Pin note, and puts Later and Today inside Move to. A leaf selection changes the local status. A disabled entry remains visible but cannot be selected; hiding an unavailable action is a separate application choice.
Expose more than a right-click
NibContextMenu opens at the pointer on secondary tap or long press. enableSecondaryTap and enableLongPress are independently configurable and default to true. Open menu calls the imperative helper at the note’s measured global edge, providing a keyboard-accessible path.
showNibContextMenu requires globalPosition. Compute it with RenderBox.localToGlobal at opening time; do not pass local pointer coordinates. Its Future returns a selected NibMenuItem or null. The helper targets the root overlay, so the website menu and dismissal layer use the page’s overlay.
Perform each action once
NibMenuItem.onSelected is the leaf callback. onItemSelected on the wrapper or helper also reports a selection, and the helper returns that item. Put the side effect in one of these paths to avoid duplicates.
The demo uses the wrapper callback for right-click/long-press and the awaited helper result for its button. It does not attach a second business callback to each item. enabled, destructive, icon, and trailing describe availability or appearance; destructive styling is not a confirmation mechanism.
Navigate nested entries
submenu is another list of entries; hasSubmenu reports whether it is non-empty. Sections and dividers are skipped by keyboard navigation. Up/down moves the active entry, right enters a submenu, left returns, Enter activates, and Escape closes or steps back.
Keep nesting shallow and labels recognizable. trailing may show a shortcut hint, but the menu does not register that shortcut. Test a real app binding before displaying one. The example avoids fictitious shortcut labels.
Close before leaving the workflow
The menu captures NibTheme from the opening context. animated and transition opt into motion; the default is static. The root overlay contains its barrier and levels. Previous focus is restored on closure when still attached.
The show helper returns a Future, not a cancellation handle. Check mounted before updating State after the wait. A root-overlay menu can outlive the widget that opened it, so dismiss or complete it before removing the workflow. It is not a navigation route or security boundary.
Check root and submenu bounds
Opening near an edge requires checking both the first level and its submenu. Overlay origins matter: a global position must be converted before local layout. The candidate geometry repair addresses that conversion rather than moving the target away from an edge.
The tests exercise helper selection, a disabled item, a submenu, and the long-press wrapper. Physical touch latency, platform context-menu interception, and screen-reader discovery remain separate checks. Keep the explicit button available when pointer hardware is absent.