public class ContextMenu extends Widget:
Popup menu opened at an arbitrary pointer position.
ContextMenu deliberately resolves the same Menu KSS rule and uses the same layout metrics as MenuBar popups. Context menus therefore keep an identical font, row height and padding in every theme and zoom level.
menu = ContextMenu()
menu.setItems([MenuItem("Open"), MenuItem("Delete")])
menu.selected += lambda(event: ContextMenuEvent): print(event.item.text)
menu.open(0, 0, window.width, window.height, mouseX, mouseY)A pointer press outside the popup closes it automatically. The press is then routed normally to the widget under the pointer.
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | isOpenisOpen as Boolean: |
Returns whether the popup is currently opened. |
| Modifier and Type | Member | Description |
|---|---|---|
| public event | selectedselected as ContextMenuEvent |
Emitted after a menu item is selected. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | ContextMenuContextMenu(): |
Creates an initially closed context menu. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | closeclose() as Void: |
Closes the popup and clears its transient hover state. |
| public | open | Opens the popup inside an overlay layer. |
| public override | paintOverlaypaintOverlay(painter as Painter) as Void: |
No summary. |
| public | popupContainsPoint | Returns whether a point lies inside the visible popup surface. |
| public | setItems | Replaces the menu entries. |
| public | setLabels | Replaces the menu entries with text-only items. |