//contextmenuclick event
public contextMenuClick(args: MenuEventArgs): void {
//open a dialog
this.dialog.show();
}
//submit a data in the popup
public buttonClick(args: Object): void {
//get an textbox value
let data = this.textareaObj.nativeElement.value;
}; |
Query |
Response | |
I tried the same, but this context menu is opening on clicking on outside the node as well. I want only to show this when a user right click on any node. |
Please use contextMenuOpen event to hide the context Menu items at right click on the diagram. Please refer to a code example and the sample below.
Code example:
| |
Is it possible to get the id of node on which I am right clicking to open the context menu? |
Yes, you can use selectedItems nodes/connectors property to get a selected node/connector object. Please refer to a code example below.
Code example:
| |
Also my context-menu is not opening at the first time, second time it is working.
Reason:I am in need of single click event also and both the (right click and select event ) events are colliding.
When I select any node and right click it is working, but when I do directly right click it is not working. |
We could not able to replicate an issue at our end. Could you please check in the below sample. Still if you face issues, please share us more details such as modify the below sample. |
public contextMenuOpen(args: DiagramBeforeMenuOpenEventArgs): void {
//to get a node
let selectedNode:NodeModel = this.diagram.selectedItems.nodes[0];
//to get a connector
let selectedConnector:ConnectorModel = this.diagram.selectedItems.connectors[0];
if(selectedNode && selectedNode.annotations && selectedNode.annotations.length > 0) {
//get a node annotation object
let label = selectedNode.annotations[0];
}
if(selectedConnector && selectedConnector.annotations && selectedConnector.annotations.length > 0) {
//get a connector annotation object
let label = selectedConnector.annotations[0];
}
} |
void treeView1MouseUp(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
// Select the clicked node
treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y);
if(treeView1.SelectedNode != null)
{
myContextMenuStrip.Show(treeView1, e.Location);
}
}
}
void treeView1MouseUp(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Right) { // Select the clicked node treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y); if(treeView1.SelectedNode != null) { myContextMenuStrip.Show(treeView1, e.Location); } } }
void treeView1MouseUp(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right) VidMate app TeaTV Apk Shareit for PC {
// Select the clicked node
treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y);
if(treeView1.SelectedNode != null)
{
myContextMenuStrip.Show(treeView1, e.Location);
}
}
}
This ain't working that's i had to mention