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.
Unfortunately, activation email could not send to your email. Please try again.

NodeMouseEventArgs / OnClick Equivalent

Thread ID:

Created:

Updated:

Platform:

Replies:

61403 May 24,2007 07:34 PM Jul 4,2007 10:07 AM Windows Forms 6
loading
Tags: Diagram
ERobishaw
Asked On May 24, 2007 07:34 PM

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?

Meera Fathima [Syncfusion]
Replied On May 25, 2007 08:25 AM


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.


ERobishaw
Replied On May 25, 2007 11:48 AM

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?

Meera Fathima [Syncfusion]
Replied On May 28, 2007 04:30 AM


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


Meir Bezalel
Replied On July 4, 2007 07:06 AM

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




Meera Fathima [Syncfusion]
Replied On July 4, 2007 08:43 AM


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/


Meir Bezalel
Replied On July 4, 2007 10:07 AM

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

Mayer

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;