Nifty GUI text line break

Hi there,



at the moment I’m on the way to experience with the Nifty-GUI. I want to write a text, which looks like:

Name: Nick Steel

Age: 32

Proffesion: scientist



In each line i want a line break. I’ve tried it with n or with the wrapmode and the space-key but it isn’t the efficientest way to do it.



My code (only the screen):

[xml]

<screen id=“howiam”>

<layer id=“layer” backgroundColor="#0000" childLayout=“center”>



<panel id=“panel” height=“40%” width=“35%” valign=“top” childLayout=“center” backgroundColor="#88f8">

<interact onClick=“quit()”/>

<effect>

<!–<onStartScreen name=“move” mode=“in” direction=“top” length=“300” startDelay=“0” inherit=“true”/>

<onEndScreen name=“move” mode=“out” direction=“bottom” length=“300” startDelay=“0” inherit=“true”/>–>



<onStartScreen name=“fade” length=“5500” startDelay=“2000” inherit=“true”/>



<!–<onHover name=“pulsate” scaleFactor=“0.008” startColor="#f600" endColor="#ffff" post=“true”/>–>

</effect>

<text text=“Name: Nick SteelnAge: 32nProffesion: scientist”

font=“Interface/Fonts/Default.fnt” width=“80%” height=“100%” wrap=“true” />



</panel>

</layer>

</screen>

[/xml]



Thanks,

Tom

Inside the xml try actually pressing enter instead of putting n. That might work although I’m not sure. Alternatively if you use a properties file and read the value from there (a good idea for internationalisation anyway) then you can put a n in that property value and it will get turned into a linefeed.



I’ve not actually tried doing what you describe - however I have set multi line text from java dynamically and putting linefeeds into the string there definitely works…

Linebreaks are supported when you encode them correctly into the XML. According to the XML rules you’ll need to insert “& # 10;” (WITHOUT THE SPACES - the forum will remove them otherwise :D) to encode a 0x0A (LF) into an attribute.



[xml]text=“line1& # 10;line2”[/xml]



PS: Remember to remove the spaces between & and # that’s just to prevent the forum to mess up the text … >__<

3 Likes

Cool, thanks, it works!



(without the spaces :smiley: )