Hi,
There is a problem what I simply cannot solve and I am not sure whether I did a misake or there is a small bug in NiftyGui-s code.
The scenario is quite simple. I would like to add an element (a button for example) to a scrollPanel programatically but instead of appearing in the scrollPanel the button appears below the scrollPanel element.
Using XML works fine.
Here is a simple code:
[java]
import com.jme3.app.SimpleApplication;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.RenderManager;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.controls.label.builder.LabelBuilder;
import de.lessvoid.nifty.elements.Element;
public class Main extends SimpleApplication {
Nifty nifty;
public static void main(String[] args) {
Main app = new Main();
app.setShowSettings(false);
app.setDisplayStatView(false);
app.start();
}
@Override
public void simpleInitApp() {
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(
assetManager, inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml("Interface/newNiftyGui.xml", "start");
guiViewPort.addProcessor(niftyDisplay);
Element panel = nifty.getCurrentScreen().findElementByName("myListBox");
(new LabelBuilder("Button_ID", "qwe")).build(nifty, nifty.getCurrentScreen(), panel);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
[/java]
and the corresponting XML:
[java]
<?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” />
<style id="my-scrollpanel#scrollpanel">
<attributes backgroundColor="#ffff"></attributes>
<effect overlay="true">
<!-- this is the part that causes the problem :/ -->
<!-- <onActive name="blendMode" blendMode="multiply" post="true" /> -->
<onActive name="imageOverlay" filename="blackborder.png" imageMode="resize:1,30,1,1,1,30,1,1,1,30,1,1" post="true"></onActive>
</effect>
</style>
<style id="my-scrollpanel#bottom-right">
<attributes width="23px" height="23px"></attributes>
</style>
<screen id="start">
<layer id="layer" childLayout="center">
<panel id="panel" align="center" childLayout="center">
<control id="myListBox" name="scrollPanel" childLayout="vertical" style="my-scrollpanel">
</control>
</panel>
</layer>
</screen>
</nifty>
[/java]
(There is a style definition in the xml because another bug in Nifty-s code… just ignore it.)
Anyone can reproduce the problem?
Any comment is greaty appreciated!
Thank you