Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom node to expand shrink based on content (Read 2466 times)
dittu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 20
Joined: Feb 6th, 2015
Custom node to expand shrink based on content
Feb 6th, 2015 at 10:36am
Print Post  
I have created custom node having image and text below it, referring custom node sample provided with the download.

Scenario is in some case text might be there, minimal text and very large text, so, I want my node to shrink expand based on the amount of text. resize to fit etc. options are not working for me. Please provide some help on this.

Thanks in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom node to expand shrink based on content
Reply #1 - Feb 6th, 2015 at 11:59am
Print Post  
There's undocumented diagram.measureString: function (text, font, bounds, styled) you could call to measure the text and resize the node based on returned size. E.g. ShapeNode's resizetoFitText uses it like this:

Code
Select All
...
var rc = this.bounds.clone();
var size = this.parent.measureString(text, font, rc);
rc.height = size.height;
this.setBounds(rc, true, true);
... 



You might also want to add some margins to the rectangle or enforce minimum width for the image.

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