Nifty – Text cut off on labels when line wrapping and updating text

Hello all,



I have two problems.



The first is that my text gets cut off. Not sure why.



http://imgur.com/AspgB



[xml]<?xml version=“1.0” encoding=“UTF-8”?>

<nifty xmlns=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd”>



<useControls filename=“nifty-default-controls.xml” />

<useStyles filename=“nifty-default-styles.xml” />



<screen id=“start” controller=“mygame.BasicText”>





<layer id=“control_layer” backgroundColor="#fff0" childLayout=“vertical”>



<panel id=“top_panel_1” height=“25%” width=“100%” childLayout=“horizontal” backgroundColor="#f00f">

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</panel>



<panel id=“top_panel_1” height=“10%” width=“100%” childLayout=“horizontal” backgroundColor="#ffff">

<panel id=“side_panel” height=“100%” width=“30%” childLayout=“center” align=“center” backgroundColor="#0f0f">

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</panel>

<panel id=“another_panel” height=“100%” width=“40%” childLayout=“center” align=“center” backgroundColor="#aaaf">

<control id=“another_label1” name=“label” font=“Interface/Fonts/Console.fnt” text=“Hello title. No wrapping required.” color="#000f" >

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</control>

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</panel>

<panel id=“side_panel_2” height=“100%” width=“30%” childLayout=“center” align=“center” backgroundColor="#ff0f">

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</panel>

</panel>



<panel id=“top_panel_1” height=“40%” width=“100%” childLayout=“horizontal” backgroundColor="#ffff">

<panel id=“side_panel” height=“100%” width=“30%” childLayout=“center” align=“center” backgroundColor="#0fff">

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</panel>

<panel id=“another_panel” height=“100%” width=“40%” childLayout=“center” backgroundColor="#aaaf">

<control id=“another_label2” name=“label” font=“Interface/Fonts/Console.fnt” width=“90%” height=“90%” textVAlign=“top” textHAlign=“left” wrap=“true” text=“The quick brown fox jumped the lazy dog. The quick brown fox jumped the lazy dog. The quick brown fox jumped the lazy dog. The quick brown fox jumped the lazy dog. The quick brown fox jumped the lazy dog. " color=”#000f">

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</control>

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</panel>

<panel id=“side_panel” height=“100%” width=“30%” childLayout=“center” align=“center” backgroundColor="#00ff">

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>

</panel>

</panel>



<panel id=“top_panel_1” height=“25%” width=“100%” childLayout=“horizontal” backgroundColor="#333f">

<effect>

<onActive name=“border” color="#000f" border=“2px” />

</effect>



</panel>

</layer>

</screen>

</nifty>[/xml]





The second is that when I update each Label’s text via Java, the wrapping is lost.



This is what I do to update the text of each label



[java]Label labelText = s1.findNiftyControl(“another_label1”, Label.class);



labelText.setText(“Some silly string is not actually silly string. Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.Some silly string is not actually silly string.”);



Element niftyElement1 = s1.findElementByName(“another_label1”);



niftyElement1.getRenderer(TextRenderer.class).setLineWrapping(true);[/java]



If anyone can shed some light on either of these issues, it would be most helpful.

Hello again



The above xml layout was going to going to be used as a popup on a nifty HUD. Other popups are working, but this one, which needed to wrap text was a problem.



I have resolved the problem by using the PopupBuilder() :slight_smile:



Here’s a example of the code I used



[java]public void createDialoguePopup(String s, String ss)

{

final String s1 = s;

final String s2 = s;



new PopupBuilder(“dialoguePopup”) {{



childLayoutVertical();



panel(new PanelBuilder() {{

height(“30%”);

}});



text(new TextBuilder(“dialoguePopupTitleText”) {{

alignCenter();

height(“50%”);

width(“50%”);

backgroundColor("#0ff1");

color("#0f0f");

font(“Interface/Fonts/Default.fnt”);

wrap(true);

textHAlignLeft();

textVAlignTop();

text(s1);

interactOnClick(“exitDialoguePopup()”);

}});



text(new TextBuilder(“dialoguePopupText”) {{

alignCenter();

height(“50%”);

width(“50%”);

backgroundColor("#0ff1");

color("#0f0f");

font(“Interface/Fonts/Default.fnt”);

wrap(true);

textHAlignLeft();

textVAlignTop();

text(s2);

interactOnClick(“exitDialoguePopup()”);

}});



}}.registerPopup(nifty);[/java]



Sorry if I wasted anyone’s time!!