Reference
ContextMenu
What it wraps, and a menu a right-click, a long press, the menu key or Shift+F10 inside it opens where it happened.
ContextMenu { … }
Since 6.2.0
No props to try.
Right-click the file, or focus it and press Shift+F10
Example
state said = "Right-click the file, or focus it and press Shift+F10"
ContextMenu {
Card.outlined {
Row(gap: .sm, align: .center) {
Icon("file")
Text("quarterly-report.pdf")
}
}
ContextMenu.Items(label: "File actions") {
Menu.Item(shortcut: "mod+o") { on click { said = "Opened" } Text("Open") }
Menu.Item(shortcut: "F2") { on click { said = "Renamed" } Text("Rename") }
Menu.Divider
Menu.Item.danger { on click { said = "Deleted" } Text("Delete") }
}
}
Text(said).muted.sm
Props
This element takes no props of its own.
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
No flags of its own.
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Parts
The parts of ContextMenu are written under its name, inside it. Each is described here, with what it takes.
ContextMenu.Items
The menu: Menu.Items, Menu.Subs and Menu.Dividers.
ContextMenu.Items(label: String) { … }
| Prop | Type | Unset | Meaning |
|---|---|---|---|
label: | String | none | The menu's accessible name ( |
Renders with the class wf-context-menu, stable across releases, so a stylesheet may target it.
Codes this can raise
These controls list the props' cases; the example below shows them written.