Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Shape move selection position (Read 5046 times)
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Shape move selection position
Apr 29th, 2013 at 9:41am
Print Post  
Hi,

Currently I can only move the shape by clicking on the center of the shape. Is there any option to move the shape by clicking anywhere in the border of the diagram. I need this coz if i move the shape out of the diagram canvas, sometimes i wont  be able to get the move handle. This time the center will be outside the canvas diagram. So i need this feature. Is there any hack for this?

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Shape move selection position
Reply #1 - Apr 29th, 2013 at 12:37pm
Print Post  
You will have to override the handleAtPoint function:

Code
Select All
var originalHandleAt = ShapeNode.prototype.handleAtPoint;
ShapeNode.prototype.handleAtPoint = function (point)
{
	var handle = originalHandleAt.apply(this, [point]);
	if (handle != null)
		return handle;
	if (this.containsPoint(point))
		return { item: this, index: 8 };
	return null;
}; 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Shape move selection position
Reply #2 - May 1st, 2013 at 8:17am
Print Post  
Hi,

I fact we have to give the code like below, otherwise error will be thrown saying that ShapeNode is null.

var originalHandleAt = MindFusion.Diagramming.ShapeNode.prototype.handleAtPoint;
        MindFusion.Diagramming.ShapeNode.prototype.handleAtPoint = function (point) {
            
            var handle = originalHandleAt.apply(this, [point]);
            if (handle != null)
                return handle;
            if (this.containsPoint(point))
                return { item: this, index: 8 };
            return null;
        };

But after i put this code nothing happens. Still the move handle is at the center. Could you please check this.

Also could you please tell me the expected behaviour? Also what is the below line doing?
if (this.containsPoint(point))
                return { item: this, index: 8 };

Thanks
Kiran B

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Shape move selection position
Reply #3 - May 1st, 2013 at 9:06am
Print Post  
Yes, I had a var ShapeNode = MindFusion.Diagramming.ShapeNode; in the test page, you can use that too to avoid repeating the namespace. That replaces only the ShapeNode's method, since you are also using containers, you might need to do the same for ContainerNode class.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Shape move selection position
Reply #4 - May 1st, 2013 at 9:20am
Print Post  
Hi,

you didn't answer my second question
But after i put this code nothing happens. Still the move handle is at the center. Could you please check this.

Also could you please tell me the expected behaviour? Also what is the below line doing?
if (this.containsPoint(point))
                return { item: this, index: 8 };
Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Shape move selection position
Reply #5 - May 1st, 2013 at 11:55am
Print Post  
That code lets you move the node by dragging from anywhere within the shape. It does not draw the move handle at a different position.
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Shape move selection position
Reply #6 - May 1st, 2013 at 6:50pm
Print Post  
Hi Stoyan,

Sorry i was trying with container node that's why nothing was heppening for me. I replaced ShapeNode with ContainerNode and its working great. Its even drawing the move handle. Thanks.

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Shape move selection position
Reply #7 - May 10th, 2013 at 6:24am
Print Post  
Hi,

I have just noticed some refresh lag in my test app while drawing nodes interactively due to above function. Use this version of the code instead:

Code
Select All
var originalHandleAt = ShapeNode.prototype.handleAtPoint;
ShapeNode.prototype.handleAtPoint = function (point)
{
	var handle = originalHandleAt.apply(this, [point]);
	if (handle != null)
		return handle;
	if (!this.selected)
		return null;
	var bounds = this.getRotatedBounds();
	if (!bounds.containsPoint(point))
		return null;
	if (MindFusion.Diagramming.Utils.pointInPolygon(point, this.getOutline()))
		return { item: this, index: 8 };
	return null;
}; 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Shape move selection position
Reply #8 - May 10th, 2013 at 8:14am
Print Post  
Hi Stoyan,

Thanks a lot for these sort of follow ups. Really great. I will update.

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