Skip to content

Context Menu ​

Right-click menu fixed at the pointer position. The theme's event layer suppresses the native menu, records the pointer, and focuses the first item.

Examples ​

Right-click the tile ​

moonbit
@sumi.context_menu(
  entries=[
    @sumi.Item(@sumi.MenuItem::new("rename", "Rename", shortcut="R")),
    @sumi.Separator,
    @sumi.Item(@sumi.MenuItem::new("delete", "Delete", shortcut="⌫")),
  ],
  open=is_open,
  on_open_change=set_open.map(v => _ => v),
  on_select=set_action.map(v => _ => v),
  target_content,
)

API ​

context_menu ​

NameTypeDefaultDescription
entries *Array[MenuEntry]—Menu content — Item, Separator, SectionLabel
open *Bool—Whether the overlay is open (controlled)
on_open_changeEmit[Bool]—Called when the open state should change
selectedString—Value of the currently selected item
on_selectEmit[String]—Called with the value of the picked item
idString—Element id
classString—Extra class names
attrsAttrs—Extra HTML attributes
styleArray[String][]Extra inline styles
menu_styleArray[String][]Styles for the floating panel
childrenC—Content

* required (labelled) parameter — everything else is optional.