[Fixed] centerLayout multiple childs warning

I get the warning “WARNING: You’re using a centerLayout element but you’ve added more than one child element to it. centerLayout only supports one element! Odd things will happen when used with more than one element :)”, but I can’t find my mistake.



Can anyone find it?



[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”>

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

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





<screen id=“popupscreen”>

<layer id=“background” backgroundColor="#00000000">

</layer>

</screen>





<popup id=“popup” controller=“client._gui.NiftyApp_Popup” childLayout=“center” backgroundColor="#00000055">

<effect>

<onStartScreen name=“fade” start="#0" end="#f" length=“600” />

<onEndScreen name=“fade” start="#f" end="#0" length=“600” />

</effect>



<panel height=“40%” width=“40%” childLayout=“vertical” align=“center” backgroundColor="#999999ff">

<panel height=“4” width="" />

<panel height="
" width="" childLayout=“horizontal” align=“center” backgroundColor="#00000000">

<panel height="
" width=“4” />





<panel height="" width="" childLayout=“vertical” align=“center” valign=“center” backgroundColor="#666666ff">

<panel height=“4%” width="" />



<panel height="
" width="" childLayout=“center” backgroundColor="#00000000">

<control name=“scrollPanel” height=“100%” width=“95%” childLayout=“center” horizontal=“false” vertical=“true”>

<text height=“100%” width=“100%” id=“text” font=“Interface/Fonts/Default.fnt” align=“left” valign=“top” wrap=“true” text=“test” />

</control>

</panel>



<panel height=“5%” width="
" />



<panel height=“20%” width="" align=“center” valign=“center” childLayout=“center” backgroundColor="#00000000">

<control name=“button” id=“Button_Ok” label=“OK” align=“center” valign=“center”>

<interact onClick=“ok()”/>

</control>

</panel>



<panel height=“5%” width="
" />

</panel>





<panel height="" width=“4” />

</panel>

<panel height=“4” width="
" />

</panel>

</popup>





</nifty>

[/xml]

It looks fine at first glance, maybe it’s something to do with the controls?

Try commenting out sections of the XML and narrow down which bit is causing the error.

It looks like this causes it, but I don’t know why:



[xml] <panel height="" width="" childLayout=“center” backgroundColor="#00000000">

<control name=“scrollPanel” height=“100%” width=“95%” childLayout=“center” horizontal=“false” vertical=“true”>

<text height=“100%” width=“100%” id=“text” font=“Interface/Fonts/Default.fnt” align=“left” valign=“top” wrap=“true” text=“test” />

</control>

</panel>[/xml]

Found it, but still don’t know why it gives a warning, it’s the scrollpanel:

[xml] <control name=“scrollPanel” height=“100%” width=“95%” childLayout=“center” horizontal=“false” vertical=“true”>

<text height=“100%” width=“100%” id=“text” font=“Interface/Fonts/Default.fnt” align=“left” valign=“top” wrap=“true” text=“test” />

</control>[/xml]



Setting wrap to false didn’t fix it, so that’s not it either. Changing childLayout to vertical did fix it, but it only has 1 element, so how can this give that warning?

The scroll panel will be containing a number of objects as part of the control (things like scroll bars etc).



Probably you are supposed to attach a single panel into the scroll panel then put whatever you like inside that panel.

But the panel won’t resize with the text then… I guess setting it to vertical is the right thing to do, haven’t seen any side-effects yet.