I have used the custom context menu and the context menu is working fine on click. But the context menu is not working on click on button and it work for textblock. You can see the below code and added the context menu outside the button and it works. But if I add the same code in the button, the context menu is not showing.
const myContextMenu = $(go.HTMLInfo, {
show: this.showContextMenu,
hide: this.hideContextMenu
});
var linkTemplate =
$(go.Link,
{
curve: go.Link.Bezier,
adjusting: go.Link.Stretch,
selectionAdorned: false,
corner: 20,
}, {
fromPortChanged: this.updateLinkColor,
toPortChanged: this.updateLinkColor
}, {
reshapable: true,
resegmentable: false
},
new go.Binding("points").makeTwoWay(),
new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify),
new go.Binding("adusting").makeTwoWay(),
$(go.Shape,
{
name: "SHAPE",
strokeWidth: 2,
stroke: "#003366",
}
),
$(go.Shape, { toArrow: "Standard" }),
$(go.Panel, "Auto",
$(go.Shape, "RoundedRectangle", {
fill: "white",
strokeWidth: 2,
height: 20,
stroke: "#f5f5f5"
}
),
{
toolTip: $("ToolTip", {
"Border.fill": "#f5f5f5"
},
$(go.TextBlock, {
margin: 4
},
new go.Binding("text"))
)
},
$(go.TextBlock,
{
name: "linkTextBlock",
textAlign: "center",
font: "9pt helvetica, arial, sans-serif",
textValidation: this.validateTextLabel,
margin: 14
},
new go.Binding("editable", "", function (v) {
if (v.category === "applink") {
return false;
} else {
return true;
}
}),
new go.Binding("text", "linkText").makeTwoWay()),
{
contextMenu: myContextMenu,
click: function (e, node) {
e.diagram.commandHandler.showContextMenu(node);
},
contextClick: function (e, node) { e.handled = true; }// end Adornment
},
$("Button", {
name: "Button",
alignment: go.Spot.RightCenter,
visible: true,
},
$(go.Shape, {
figure: "PlusLine",
width: 4,
height: 4,
})
)
)
);