Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Container selection issue (Read 2751 times)
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Container selection issue
May 7th, 2013 at 10:43pm
Print Post  
I am running into an issue involving containers and dragging a selection.

Open the attached zip file and import the xml into the MindFusion Demo program. There are two containers on the screen, with a shapenode inside of the right one.

Hold control, and then select both the right container AND the node inside of it.

Select and drag the two selected items into the container on the right.

Collapse the inner container and the shapenode that was inside of it when you dragged it is no longer inside of it. In our product shapenodes are getting dropped into the wrong container in various scenarios like this, involving more than one item selected and dragged into a container.

This behavior did not used to happen in an older build of our product using an older version of MindFusion.
  

container_selection_issue.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Container selection issue
Reply #1 - May 8th, 2013 at 4:56pm
Print Post  
What version were you using in the older build? I have tried this with v5.0 and the behavior is the same; apparently the control treats dragging multiple selected items into a container as an intent to make them children of that container, regardless if their current container is also selected. You could check if there aren't some event handlers modifying the selection in your older version that aren't running now. We'll try to improve this for the next release or add a validation event for changing containers.
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: Container selection issue
Reply #2 - May 9th, 2013 at 2:26pm
Print Post  
We upgraded to 6.0 from 5.6.2.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Container selection issue
Reply #3 - May 9th, 2013 at 5:02pm
Print Post  
The same happens in version 5.6.2 as well. If you are building from source code as you said in another post, perhaps you had some customizations in ContainerNode.cs to avoid that? In any case, we'll try to fix that in the next few days and can send you updated code when ready.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Container selection issue
Reply #4 - May 20th, 2013 at 9:49am
Print Post  
The following changes in ContainerNode.cs will fix that:

Replace the two GetFoldedContainer methods with

Code
Select All
/// <summary>
/// Retrieves the topmost folded container node (if any)
/// the specified node belongs to.
/// </summary>
internal static ContainerNode GetFoldedContainer(DiagramNode node)
{
	return FindTopmostContainer(node, null,
		delegate(ContainerNode c) { return c.Folded; });
}

/// <summary>
/// Retrieves the topmost selected container node (if any)
/// the specified node belongs to.
/// </summary>
internal static ContainerNode GetSelectedContainer(DiagramNode node)
{
	return FindTopmostContainer(node, null,
		delegate(ContainerNode c) { return c.Selected; });
}

static private ContainerNode FindTopmostContainer(
	DiagramNode node, ContainerNode topmost, Predicate<ContainerNode> condition)
{
	ContainerNode container = GetContainer(node);
	if (container != null)
	{
		if (condition(container))
			return FindTopmostContainer(container, container, condition);

		return FindTopmostContainer(container, topmost, condition);
	}

	return topmost;
} 



and in OnDropOver override replace nodes = selection.Nodes.Clone() assignment with

Code
Select All
nodes = new DiagramNodeCollection();
foreach (DiagramNode node in selection.Nodes)
	if (GetSelectedContainer(node) == null)
		nodes.Add(node); 



In effect, that should change the parent only of the outermost selected container.

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