contextMenu property

dynamic get contextMenu

This Adornment or HTMLInfo is shown upon a context click on this object. The default value is null, which means no context menu is shown.

Changing this value will not modify or remove any existing menu that is being shown for this object.

Context menus may also depend on having the same data binding as the adorned Part (i.e. the same value for Panel#data).

Context menus are not copied by #copy, so that context menus may be shared by all instances of a template.

A typical context menu is implemented as an Adornment with several buttons in it. For example, this context menu is defined in the Dynamic Port sample:

var nodeMenu =  // context menu for each Node
 $("ContextMenu",
    $("ContextMenuButton",
      $(go.TextBlock, "Add top port"),
      { click: (e, obj) => addPort("top") }),
    $("ContextMenuButton",
      $(go.TextBlock, "Add left port"),
      { click: (e, obj) => addPort("left") }),
    $("ContextMenuButton",
      $(go.TextBlock, "Add right port"),
      { click: (e, obj) => addPort("right") }),
    $("ContextMenuButton",
      $(go.TextBlock, "Add bottom port"),
      { click: (e, obj) => addPort("bottom") }));

and is used in the node template:

myDiagram.nodeTemplate =
  $(go.Node, "Table",
    { . . .
      contextMenu: nodeMenu
    },
    . . .);

Context menus are normally positioned by ContextMenuTool#positionContextMenu. However, if there is a Placeholder in the context menu, the context menu (i.e. an Adornment) will be positioned so that the Placeholder is at the same position as this adorned GraphObject.

The Basic sample also shows how to make context menu items invisible when the command is disabled.

Replacing this value will not modify or remove any existing context menu that is being shown for this object.

Read more about context menus at Context Menus.

Implementation

_i2.dynamic get contextMenu => _i4.getProperty(
      this,
      'contextMenu',
    );
set contextMenu (dynamic value)

Implementation

set contextMenu(_i2.dynamic value) {
  _i4.setProperty(
    this,
    'contextMenu',
    value,
  );
}