ContextMenu
Opens a model-driven native menu from a secondary-button press on its trigger.
#Import
Import ContextMenuState from quickgui.
use quickgui::*;#Usage
ContextMenuState::new()
.trigger().child(text("Right-click me"))#Anatomy
ContextMenuState::rootContextMenuState::trigger
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
ContextMenuState
View sourcepub const fn new() -> Selfpopover_windowpub const fn popover_window(self) -> Option<WindowHandle>—
Configures popover window for this part.
pub const fn popover_window(self) -> Option<WindowHandle>View sourceis_openpub const fn is_open(self) -> bool—
item_statepub fn item_state( menu: &PopoverMenu, index: usize, submenu_open: bool, ) -> Option<MenuItemPartState>—
The Base UI-named render snapshot for one row of an open context menu. The native popover surface resolves its own placement against the display work area, so a context menu publishes row state rather than the popup's side and alignment.
pub fn item_state( menu: &PopoverMenu, index: usize, submenu_open: bool, ) -> Option<MenuItemPartState>View sourceclosepub fn close(&mut self, cx: &mut EventContext) -> bool—
Close the current root context-menu surface synchronously from application state.
pub fn close(&mut self, cx: &mut EventContext) -> boolView sourceContextMenuState::target_with
View sourcepub fn target_with(self, id: impl Into<ElementId>, target: Element) -> ElementDecorate a caller-owned target with context-menu semantics without changing appearance, focusability, pointer cursor, drag-region behavior, layout, or ordinary click handling.
ContextMenuState::target
View sourcepub fn target(self, id: impl Into<ElementId>) -> ElementCreate the unstyled target part. Use [`Self::target_with`] to supply an existing element.
ContextMenuState::trigger_with
View sourcepub fn trigger_with(self, id: impl Into<ElementId>, trigger: Element) -> ElementDecorate a caller-owned target, Base UI's `ContextMenu.Trigger`. This is the Base UI-named alias of [`Self::target_with`]; both names decorate the same element identically.
ContextMenuState::trigger
View sourcepub fn trigger(self, id: impl Into<ElementId>) -> ElementCreate the unstyled trigger part. Use [`Self::trigger_with`] to supply an existing element.
ContextMenuState::backdrop_with
View sourcepub fn backdrop_with(self, id: impl Into<ElementId>, backdrop: Element) -> ElementDecorate an optional caller-painted backdrop, Base UI's `ContextMenu.Backdrop`. The native popover surface already takes the pointer grab, so this layer exists only for a caller-painted dimming pass inside the owner window. It is hidden from assistive technology and carries no appearance of its own. Mount it only while [`Self::is_open`] is true.
ContextMenuState::backdrop
View sourcepub fn backdrop(self, id: impl Into<ElementId>) -> ElementCreate the unstyled backdrop part. Use [`Self::backdrop_with`] to supply an existing element.
ContextMenuState::element
View sourcepub fn element<V, BuildMenu, RenderRoot, RenderItem>( self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, access: fn(&mut V) -> &mut ContextMenuState, target: Element, layout: ContextMenuLayout, build_menu: BuildMenu, render_root: RenderRoot, render_item: RenderItem, ) -> Element where V: 'static, BuildMenu: Fn(&mut V, &ContextMenuEvent) -> Option<PopoverMenu> + 'static, RenderRoot: Fn() -> Element + 'static, RenderItem: Fn(&PopoverMenuItem, PopoverMenuItemState) -> Element + 'static,Attach a complete cursor-point popover-menu interaction to a caller-owned target. `build_menu` runs only on a secondary click and may return `None` to suppress the popover. `render_root` and `render_item` own all appearance. The framework owns only bounded model behavior, structural geometry, point placement, separate-surface lifetime, keyboard focus, dismissal, submenu parenting, and exact native-close synchronization.
ContextMenuState::element_with
View sourcepub fn element_with<V, BuildMenu, RenderRoot, RenderItem>( self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, access_source: StateAccessor<V, ContextMenuState>, target: Element, layout: ContextMenuLayout, build_menu: BuildMenu, render_root: RenderRoot, render_item: RenderItem, ) -> Element where V: 'static, BuildMenu: Fn(&mut V, &ContextMenuEvent) -> Option<PopoverMenu> + 'static, RenderRoot: Fn() -> Element + 'static, RenderItem: Fn(&PopoverMenuItem, PopoverMenuItemState) -> Element + 'static,Attach the cursor-point popover-menu interaction against a per-instance state accessor. A host that owns one [`ContextMenuState`] per declared target passes an accessor that captures which state this target opens into.
