ContextMenu
class in package klyn.gui.windows

    public class ContextMenu extends Widget:

Widget
└ ContextMenu

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.

Properties

Modifier and Type | Member | Description
--- | --- | ---
public readonly property | isOpen `isOpen as Boolean:` | Returns whether the popup is currently opened.

Inherited Properties
property Inherited Properties from Widget: accentColor, backgroundColor, borderColor, bottom, canFocus, cornerRadius, cursor, font, foregroundColor, hasFocus, height, isEnabled, isHovered, isManaged, isTabStop, isVisible, layoutParams, margin, maxHeight, maxWidth, minHeight, minWidth, parent, preferredHeight, preferredWidth, resolvedStyleCache, resolvedStyleCacheAppearanceMode, resolvedStyleCacheFont, resolvedStyleCacheRevision, resolvedStyleCacheStateKey, resolvedStyleCacheStyleClass, resolvedStyleCacheZoomRevision, right, size, sizePolicy, styleClass, toolTip, width, window, x, y
Events

Modifier and Type | Member | Description
--- | --- | ---
public event | selected `selected as ContextMenuEvent` | Emitted after a menu item is selected.

Inherited Events
event Inherited Events from Widget: keyPressed, keyReleased, mouseMoved, mousePressed, mouseReleased, mouseWheel, paintRequested, resized
Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | ContextMenu `ContextMenu():` | Creates an initially closed context menu.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | close `close() as Void:` | Closes the popup and clears its transient hover state.
public | open `open(layerX as Int, layerY as Int, layerWidth as Int, layerHeight as Int, menuX as Int, menuY as Int) as Void:` | Opens the popup inside an overlay layer.
public override | paintOverlay `paintOverlay(painter as Painter) as Void:` | No summary.
public | popupContainsPoint `popupContainsPoint(x as Int, y as Int) as Boolean:` | Returns whether a point lies inside the visible popup surface.
public | setItems `setItems(items as List<MenuItem>) as Void:` | Replaces the menu entries.
public | setLabels `setLabels(labels as List<String>) as Void:` | Replaces the menu entries with text-only items.

Inherited Methods
method Inherited Methods from Widget: blur, containsPoint, emitKeyPressed, emitKeyReleased, emitMouseMoved, emitMousePressed, emitMouseReleased, emitMouseWheel, handleTabKey, notifyPaintRequested, paint, paintClipped, paintOverlay, repaint, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds