Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Default Node Selection (Read 1950 times)
dittu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 20
Joined: Feb 6th, 2015
Default Node Selection
Apr 2nd, 2015 at 7:25am
Print Post  
Hi Stoyo,

I want to select the default node on load on diagram. How can I fire nodeClicked event of my default diagramNode, once page is loaded?
Secondly, the text goes out of bounds if there are no whitespaces in it, i.e wrapping doesn't happen if text is too long without whitespaces. Can you help on these issue?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Default Node Selection
Reply #1 - Apr 2nd, 2015 at 9:11am
Print Post  
Hi,

You could call DiagramItem.setSelected(true) to select initial node.

If using ShapeNodes you could set their EnableStyledText property to wrap long words - but it also parses some html tags for fonts and colors and formats the text.

If not using ShapeNodes or you prefer not to parse and format the text, you could replace MindFusion.Drawing.Text.wrapLine function with your own version that will also split long words:

Code
Select All
var originalWrapLine = MindFusion.Drawing.Text.wrapLine;
MindFusion.Drawing.Text.wrapLine = function (context, text, maxWidth, lines)
{
	originalWrapLine.apply(this, [context, text, maxWidth, lines]);
	for (var i = 0; i < lines.length; i++)
	{
		var line = lines[i];
		var w = context.measureText(line).width;
		if (w > maxWidth)
		{
			var c = 1;
			var fittingPart = "";
			do
			{
				fittingPart = line.substring(0, c);
				w = context.measureText(fittingPart).width;
				c++;
			}
			while (w < maxWidth);
			var remaining = line.substring(c - 1);
			lines[i] = fittingPart;
			if (remaining != "")
				lines.splice(i + 1, 0, remaining);
		}
	}
}; 



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