Skip to main content

context_menu

Function context_menu 

Source
pub fn context_menu(ui: &mut Ui<'_>, at: Vec2, items: &[MenuItem]) -> Key
Expand description

Draws a context menu at at (logical viewport px) and returns the key of its root. A float anchored to the viewport rather than to a parent, because a context menu belongs at the pointer and not under whatever node happens to enclose it; fit is what keeps it in the window, which for a menu near the bottom edge means flipping above the point.

It declares modal, so a press outside it or Escape emits a dismiss event on it rather than through a dismissal rule of its own; the caller closes it when that dismissal arrives. The rows are menuItems under a menu, which is what makes the arrow keys work and what a screen reader reads.

Each chosen row posts the item’s id, or its label when it declares none. A Separator posts nothing and takes no focus.