Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Container anchors: Connection dragging bug? (Read 661 times)
CompaniaHill
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Jul 14th, 2023
Container anchors: Connection dragging bug?
Jul 14th, 2023 at 4:32pm
Print Post  
We have created a tool class that adds connection anchors to containers. (We use custom Draw code to render the anchor's appearance slightly outside the container's Bounds, but that is not important for this question.)

While using the mouse to drag a new connection line from a source tool's anchor to a destination tool, when the mouse is anywhere within the bounds of the destination tool, the connection line will snap to the destination tool's input anchor. When the mouse is out in the open canvas far from any tools, the connection line does not snap, and releasing the mouse will drop the connection line without completing a new connection.

This behavior makes sense for a normal tool, but not for a container with an input anchor. If the user wants to connect to a tool within such a container, dragging onto the inner tool will still connect correctly. But while dragging anywhere else within the container's canvas, the new connection line will snap to the container's input anchor. The container becomes very "greedy." This makes connecting to tools within that container very difficult.  And releasing the mouse anywhere within the container's canvas will complete this unwanted connection rather than dropping it.

We have found no possible way around this behavior. While dragging a new connection line, the MindFusion code does not even call any of our container's callback methods such as HitTest() or HitTestHandle().

We believe this is a bug that will require a code fix within the MindFusion library. We would be fine if dragging a connection line over a container's top header would still snap to that container's input anchor. But we request that dragging a connection line over a container's internal canvas should NOT snap to that container's input anchor.

Thank you.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Container anchors: Connection dragging bug?
Reply #1 - Jul 17th, 2023 at 4:10pm
Print Post  
If you set AllowUnanchoredLinks to false, you can prevent links connecting to container except from caption area by handling ValidateAnchorPoint event:

Code
Select All
void OnValidateAnchorPoint(object sender, LinkValidationEventArgs e)
{
	var ctr = e.Node as ContainerNode;
	if (ctr != null)
	{
		var bounds = ctr.Bounds;
		bounds.Height = ctr.CaptionHeight;
		if (!bounds.Contains(e.MousePosition))
			e.Cancel = true;
	}
} 



Or alternatively you could check the distance to input anchor point in the handler.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
CompaniaHill
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Jul 14th, 2023
Re: Container anchors: Connection dragging bug?
Reply #2 - Jul 27th, 2023 at 3:59pm
Print Post  
Slavcho --

I've added an appropriate check to our OnValidateAnchorPoint() and it works great.  Thanks for pointing me to this!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint