Label text wrapping

I’ve seen that’s possibile tu wrap label text

[xml]<label text="ciao ciao ciao ciao ciao ciao ciao ciao ciao " id=“commentText” width=“98%” height=“98%”

font =“fonts/verdana_11_bold.fnt” wrap=“true” textHAlign=“left” textVAlign=“top” align=“left” />[/xml]



but if I change text from code, I loose wrap property. I can’t find how to set it again from code

thanks in advance

bye

1 Like

you mean, after you’ve set the text it does not automatically wrap again?



I can’t check right now but can you try a screen.layout() call after you’ve set the new text for the label if that fixes the problem? Thanks.

Bump.

I have run into the same problem, and the closest i come to “layout()” in Screen is “layoutLayers()”, which doesn’t seem to solve the problem (neither does layoutElements() ).



Thanks.

What Nifty version do you use? 1.2? The one bundled with JME3?



I’ve tried this code with the current Nifty SVN (1.3-SNAPSHOT):



[java] public final void onStartScreen() {

screen.findElementByName(“commentText”).getRenderer(TextRenderer.class).setText("bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla ");

screen.layoutLayers();

}[/java]



And it works correctly! There have been some changes after 1.2 to SVN that fixed some bugs with wrap=“true” and I think your issue was solved too.

Alright, thanks.



I’m currently using the bundled one. Will download 1.3 instead.