Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Dragging nodes with right mouse button (Read 2223 times)
VT22
YaBB Newbies
*
Offline



Posts: 6
Joined: Jul 16th, 2010
Dragging nodes with right mouse button
Jul 16th, 2010 at 12:49pm
Print Post  
Hi!

Is it possible to drag diagram nodes with right mouse? I'd like to use the control with two mouse buttons: left for creating nodes and links, right for moving nodes /and also forget node selections/.

I've tried to create a custom behavior, but the StartDraw is not called on pressing RMB.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging nodes with right mouse button
Reply #1 - Jul 16th, 2010 at 1:05pm
Print Post  
Hi,

Unfortunately StartDraw is called only when using the left button. You might try overriding behavior.OnMouseMove instead, and if the right-button flag in Control.MouseButtons is enabled, set Diagram.Interaction to an InteractionState you would otherwise return from StartDraw:

if (Diagram.Interaction == null && (Control.MouseButtons & MouseButtons.Right) != 0)
     Diagram.Interaction = new InteractionState(...);

or call the base OnMouseMove implementation if the RMB flag is not set.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
VT22
YaBB Newbies
*
Offline



Posts: 6
Joined: Jul 16th, 2010
Re: Dragging nodes with right mouse button
Reply #2 - Jul 16th, 2010 at 2:04pm
Print Post  
It does not work. When I tried to move a node with RMB it was not drawn (although the cursor remained cross), and when I released the button the base threw an ArgumentNullException (on "Parameter name: image" - ???)

protected override void OnMouseMove(Point mousePosition)
{
if (Diagram.Interaction == null && ((Control.MouseButtons & MouseButtons.Right) != 0))
{
PointF point = DiagramView.ClientToDoc(mousePosition);
DiagramNode node = Diagram.GetNodeAt(point);
if (node != null)
{
Diagram.Interaction = new InteractionState(node, 8, Action.Modify);
}
}
else
{
//Diagram.Interaction = null; //with this line no exception, but no moving too
base.OnMouseMove(mousePosition);
}
}
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging nodes with right mouse button
Reply #3 - Jul 16th, 2010 at 3:15pm
Print Post  
Ok, the base class expects some back-buffer image to be created at that point and it won't be easy to create it without the reflection API. Our developer will add a MouseButtonActions member you could assign to RightButtonAction to let you override StartDraw in that case. For now you might use the shift or control keys to start the alternative action.

Stoyan
  
Back to top
 
IP Logged
 
VT22
YaBB Newbies
*
Offline



Posts: 6
Joined: Jul 16th, 2010
Re: Dragging nodes with right mouse button
Reply #4 - Jul 19th, 2010 at 9:05am
Print Post  
Thank you in advance. When will be the fix released?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging nodes with right mouse button
Reply #5 - Jul 19th, 2010 at 11:05am
Print Post  
This build adds a Draw member to the MouseButtonActions enum:
https://mindfusion.eu/_beta/fcnet54_rmb.zip

Now you can set DiagramView.RightButtonActions = Draw, and the control will also call behavior.StartDraw when the right button is down. Then you could override it like this:

Code
Select All
public override InteractionState StartDraw(PointF point)
{
	if ((Control.MouseButtons & MouseButtons.Right) != 0)
	{
		DiagramNode node = Diagram.GetNodeAt(point);
		if (node != null)
			return new InteractionState(node, 8, Action.Modify);
	}

	return base.StartDraw(point);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint