Skip to content

@vttforge/types / ContextMenuEntry

Interface: ContextMenuEntry ​

One entry of a context menu.

v14 renamed three fields: name is label, condition is visible, and callback is onClick. The old names still work and log a deprecation warning; they are removed in v16. Both shapes are described here, and the v14 ones are the ones to write.

Properties ​

callback? ​

optional callback?: (target) => void

Parameters ​

target ​

HTMLElement

Returns ​

void

Deprecated ​

v14 calls this onClick, and hands it the event first. Removed in v16.


classes? ​

optional classes?: string


condition? ​

optional condition?: boolean | ((target) => boolean)

Deprecated ​

v14 calls this visible. Removed in v16.


group? ​

optional group?: string


icon? ​

optional icon?: string


label? ​

optional label?: string

The text on the entry.


name? ​

optional name?: string

Deprecated ​

v14 calls this label. Removed in v16.


onClick? ​

optional onClick?: (event, target) => unknown

Two arguments, unlike the v13 callback, which took only the row.

Parameters ​

event ​

Event

target ​

HTMLElement

Returns ​

unknown


visible? ​

optional visible?: boolean | ((target) => boolean)

Whether to draw the entry at all.

Both this and onClick receive the row the menu was opened on, not a document. Resolve the document from the element's dataset.

MIT licensed.