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 as ContextMenuEvent): print(event.item.text)
menu.open(0, 0, window.clientWidth, window.clientHeight, mouseX, mouseY)A pointer press outside the popup closes it automatically. The press is then routed normally to the widget under the pointer. Menus taller than their overlay remain inside it and expose a mouse-wheel scrollbar. The scrollbar supports track clicks and dragging. Up/Down, PageUp/PageDown and Home/End navigate enabled entries and reveal them automatically; Right/Left enter/leave submenus, Enter activates and Escape dismisses. Closing restores the widget that had focus before the menu opened.
| 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 | ContextMenu | 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 override | handleTabKey | Keeps Tab navigation inside the open popup instead of changing editors. |
| 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. |