On click of a button present on the Node, we should be able to show some options in a dropdown menu.
Sure, that really isn’t any different than context menus. Under what conditions would you expect those “options” to disappear?
var popupCommands =
$("ContextMenu",
$("ContextMenuButton",
$(go.TextBlock, "Copy"),
{ click: function(e, button) {
var node = button.part.adornedPart;
e.diagram.select(node);
e.diagram.commandHandler.copySelection();
}
}),
$("ContextMenuButton",
$(go.TextBlock, "Delete"),
{ click: function(e, button) {
var node = button.part.adornedPart;
e.diagram.select(node);
e.diagram.commandHandler.deleteSelection();
}
})
);
myDiagram.nodeTemplate =
$(go.Node, "Auto",
{ contextMenu: popupCommands },
$(go.Shape,
{ fill: "white", portId: "", fromLinkable: true, toLinkable: true, cursor: "pointer" },
new go.Binding("fill", "color")),
$(go.Panel, "Table",
{ margin: 4 },
$(go.Shape, "Circle",
{ alignment: go.Spot.Right, width: 8,
click: function(e, obj) {
var node = obj.part;
e.diagram.commandHandler.showContextMenu(node);
}
}),
$(go.TextBlock,
{ row: 1, editable: true },
new go.Binding("text").makeTwoWay())
)
);