Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to do Autoresize ShapeNode? (Read 4720 times)
khurramdbg
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Mar 29th, 2010
How to do Autoresize ShapeNode?
Apr 10th, 2010 at 10:16am
Print Post  
I am writing some Text in ShapeNode.  I want when Text length Increrase ShapeNode should resize automatically. any help.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to do Autoresize ShapeNode?
Reply #1 - Apr 12th, 2010 at 2:05pm
Print Post  
Try handling NodeTextEdited on the client-side like this:
e.getNode().resizeToFitText(applet.getScriptHelper().getConstant("FitSize", "KeepHeight"));

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jgreen
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Aug 12th, 2010
Re: How to do Autoresize ShapeNode?
Reply #2 - Aug 19th, 2010 at 7:28pm
Print Post  
This works well to resize the shape node after leaving the node:
Code
Select All
        function onNodeTextEdited(sender, args) {
            var dvApplet = document.getElementById('dgvMain');
            args.getNode().resizeToFitText(dvApplet.getScriptHelper().getConstant('FitSize', 'KeepHeight'));
        }

 



but is there a way to have the shape auto size as the user types text into it? I looked at the nodeTextEditing event but that only fires when first entering the shape to begin adding text.

A work around offered was to just make the shape much bigger than needed and size down when complete but Client likes the way Visio does it (expands typing area as needed). <<Sometimes I really hate users>>

Anyways, thought I'd ask before telling him no. thanks.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to do Autoresize ShapeNode?
Reply #3 - Aug 20th, 2010 at 9:35am
Print Post  
There's nothing built-in. If you know Java, you can handle the view's enterInplaceEditMode event to get a reference to the JTextArea used to enter text, and resize it in response to the TextListener.textValueChanged event.

Stoyan
  
Back to top
 
IP Logged
 
jgreen
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Aug 12th, 2010
Re: How to do Autoresize ShapeNode?
Reply #4 - Aug 20th, 2010 at 1:48pm
Print Post  
Sounds like telling him start with a larger shape and reduce it down will be the easier answer  Wink
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: How to do Autoresize ShapeNode?
Reply #5 - Aug 2nd, 2011 at 2:46pm
Print Post  
Since my question is similar, I though I would ask it here.

Is there a way to get the text to wrap while typing? I have a node that is big. but the text is always in one link until I click out of the node.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How to do Autoresize ShapeNode?
Reply #6 - Aug 2nd, 2011 at 3:11pm
Print Post  
Following the advise above, handle the EnterInplaceEditScript event and use the following event handler:

Code
Select All
function onEnterInplaceEditScript(s, e)
{
      var control = e.getEditControl();
      control.setLineWrap(true);
} 


Regards,
Meppy
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: How to do Autoresize ShapeNode?
Reply #7 - Aug 3rd, 2011 at 9:48am
Print Post  
Just incase someone stumbles across this in a search, here is my code.

Once again , thank you meppy

Code
Select All
	  function onEnterInplaceEditScript(sender, args) {
		var control = args.getEditControl();
		control.setLineWrap(true);
	  }

	  function onTextEditing(sender, args) {
		args.getNode().resize(100, 100);
		diagram.resizeToFitItems(10.0, true);
	  }

	  function onTextEdited(sender, args) {
		var node = args.getNode();
		node.resize(nodeMinWidth, nodeMinHeight);
		node.resizeToFitText(script.getConstant('FitSize', 'KeepRatio'));
		if (node.getBounds().getHeight() < nodeMinHeight) {
		    node.resize(nodeMinWidth, nodeMinHeight);
		}
		redrawLayout();
	  }

	  function redrawLayout()
	  {
		var tl = script.createTreeLayout();
		tl.setLinkStyle(2);
		tl.arrange(diagram);
		diagram.resizeToFitItems(10.0, true);
	  }

 

  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: How to do Autoresize ShapeNode?
Reply #8 - Aug 8th, 2011 at 4:05pm
Print Post  
One problem with the code above is that, when editing the text, if you press escape, the onTextEdited() event is not fired.

Is there a fix for this, or another way I can catch this?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How to do Autoresize ShapeNode?
Reply #9 - Aug 9th, 2011 at 6:04am
Print Post  
There is currently no way (or at least I can't think of any) to be notified when the in-place editing is canceled (through Escape). You can turn off the Escape key by calling DiagramView.setInplaceEditCancelOnEsc(false);

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint