Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Changing node click/drag behaviour (Read 2971 times)
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Changing node click/drag behaviour
Jan 7th, 2011 at 3:33pm
Print Post  
Hi,

Currently we have the diagram configured so that;
1) if you click and drag the middle of a node the node will be moved
2) if you click and drag the edge of a node an arrow is created

Our users are telling us that they are finding it hard to discover how to create arrows, and also that they create arrows by mistake when instead they were intending to move a node.

Is it possible to;
1) Change it so that if the user clicks and drags anywhere in a node the node is moved
2) Display a small 'indicator' arrow at the bottom of a node, which when clicked and dragged creates a new arrow.

Thanks
Matt
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Changing node click/drag behaviour
Reply #1 - Jan 7th, 2011 at 3:56pm
Print Post  
Hi,

It is possible. For example:

Code
Select All
diagram.ShapeHandlesStyle = HandlesStyle.MoveOnly;
diagram.ModificationStart = ModificationStart.AutoHandles;
diagram.CustomBehavior = new MyBehavior(diagram);
 



where MyBehavior.StartDraw looks like this:

Code
Select All
public override InteractionState StartDraw(Point point)
{
	var node = Diagram.GetNodeAt(point);
	if (node != null)
	{
		var indicatorLocation = node.Bounds.BottomRight;
		if (Utilities.Distance(indicatorLocation, point) < 5)
		{
			var link = CreateLink();
			link.Origin = node;
			return new InteractionState(link, -1, Action.Create);
		}
	}

	return base.StartDraw(point);
} 



Also override the behavior.SetCursor method so that the control shows a different mouse pointer when over the indicator.

As for drawing the arrow indicator - if you are using ShapeNodes and their Image property is free for this, set it to the indicator image along with ImageAlign = BottomRight. Otherwise you can custom-draw it by handling DrawNode, or add it to the node template if using TemplatedNodes.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Re: Changing node click/drag behaviour
Reply #2 - Jan 7th, 2011 at 5:15pm
Print Post  
Hi Stoyan,

Thanks for this - however if I click anywhere around the edge of the node and drag it will try and create a link - is there anyway of preventing this from happening?
  
Back to top
 
IP Logged
 
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Re: Changing node click/drag behaviour
Reply #3 - Jan 7th, 2011 at 5:35pm
Print Post  
Actually forget that, by messing round with my adjustment handles I can see why this is happening.

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint