We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

NodeMouseEventArgs / OnClick Equivalent

I have implemented my own Symbol Object derived from Group (used to be of type Symbol in 4.x).

It used to be that WITHIN A NODE (formerly Symbol) the Click event, would indicate which node of a Composite node was clicked.

Now that the Onclick() event is no longer present, and OnMouseClick() doesn't provide the node... how do I go about knowing which node in the composite was clicked?

There's also no external event to the object to fire off when a Node is clicked, so I'm really stuck here.

Any ideas, other than creating a ClickableNode object that has a Click event?

6 Replies

MF Meera Fathima Syncfusion Team May 25, 2007 12:25 PM UTC


Hi Eric,

Thanks for your interest in Syncfusion products.

If your intension is to get the details about the node/composite that was clicked, you can achieve this by raising the Diagram.EventSink.NodeCollectionChanged event method. I have provided the sample code snippet which shows how to get the child node reference while clicking on a composite node( Group).

this.diagram1.EventSink.NodeCollectionChanged += new CollectionExEventHandler(EventSink_NodeCollectionChanged);

[EventHandlerPriority(true)]
void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
if (evtArgs.Element is Group)
{
Group grp = evtArgs.Element as Group;
MessageBox.Show(grp.GetChildByName("Rectangle").ToString());
}
}

Please look into it and let me know if you have any queries.

Thanks,
Meera.



ER ERobishaw May 25, 2007 03:48 PM UTC

I don't see how the example you provided will indicate which child node of the group was actually clicked.

Also...
I need to know WITHIN the group object itself (or the derived object of type Group) that a child object was clicked, and which child. Is this possible?


MF Meera Fathima Syncfusion Team May 28, 2007 08:30 AM UTC


Hi Eric,

We will analyze and will implement the desired properties to get the reference while clicking on a child node of a group node. However for now you can get this within the Diagram.EventSink.NodeCollectionChanged() event method.

Below is the sample code snippet that is used to get hold of the child node clicked.

// Nodes collection used to store child nodes of a group node while it is being added to the diagram.
NodeCollection nodes = new NodeCollection();

this.diagram1.Model.EventSink.NodeCollectionChanged += new CollectionExEventHandler(ModelEventSink_NodeCollectionChanged);
this.diagram1.EventSink.NodeCollectionChanged += new CollectionExEventHandler(EventSink_NodeCollectionChanged);

[EventHandlerPriority(true)]
void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
if (evtArgs.Element is Node)
{
Node node = evtArgs.Element as Node;
if (nodes.Contains(node) && node.Parent is MySymbol)
{
MessageBox.Show(node.Name);
}
}
}

void ModelEventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
{
if (evtArgs.ChangeType == CollectionExChangeType.Insert)
{
if (evtArgs.Element is MySymbol)
{
Group grp = evtArgs.Element as Group;
for (int i = 0; i <= grp.ChildCount; i++)
{
nodes.Add(grp.GetChild(i));
}
}
}
}

Please let me know whether the above details mentioned above are helpful to you.

Thanks for your support to Syncfusion to products.

Best Regards,
Meera



MB Meir Bezalel July 4, 2007 11:06 AM UTC

Hi Meera,

My application allows user to drag and drop a node from a palette to a diagram which is opened on the fly by the main form(the same idea as diagram builder sample).
What I need is to catch the right click event on the node.

I can catch any click event in "OnSelectionChanged" event, but how can I recognize there the doubleclick event?

Is any other solution rather than "OnSelectionChanged" event?

Thanks,

Mayer





MF Meera Fathima Syncfusion Team July 4, 2007 12:43 PM UTC


Hello Mayer,

Please find my response on your queries provided below.

1. What I need is to catch the right click event on the node.

If your intention is to catch the right click event on a node, you can use Diagram.MouseUp() event. Below is the sample code snippet for your reference.

Private Sub diagram1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
If e.Button = Windows.Forms.MouseButtons.Right AndAlso m_bShowMenu Then
If Me.diagram1.Controller.NodesHit.Count > 0 Then
'code here
Else
'code here
End If
End If
End Sub

2. I can catch any click event in "OnSelectionChanged" event, but how can I recognize there the doubleclick event?

Is any other solution rather than "OnSelectionChanged" event?

If your intention is to catch double click event either on the diagram or on a node, you can use Diagram.DoubleClick() event. If you want to catch the double click event on custom node type, you can override the OnDoubleClick() method within the custom node class.

Below is the sample code snippet for your reference.

Private Sub Diagram1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Diagram1.DoubleClick

If Me.diagram1.View.SelectionList.Count > 0 Then
' code here
Else
'code here
End If

End Sub

I hope the above details are helpful to you.

Thanks for your continued support to Syncfusion products.

Best Regards,
Meera.

Syncfusion, Inc.
http://www.syncfusion.com/



MB Meir Bezalel July 4, 2007 02:07 PM UTC

Thanks Meera, I understand my mistake.
I tried to use the form DoubleClick event rather than the diagram DoubleClick event.

Mayer

Loader.
Live Chat Icon For mobile
Up arrow icon