Hey.
I have this issue with tabs and multiple screens (and possibly listboxes), and i’d like to see if it’s only me, or some issue with nifty. Here’s a test case:
- Try out the list boxes in the tabs. They should work ok.
- Click the change screen button.
- Click it again to go back to the first screen.
- Note that the tab that was selected before changing screens is now blank.
Changing tabs back and forth shows it again, but now the list box will be irresponsive.
Example code:
Main.java
[java]public class Main extends SimpleApplication implements ScreenController {
private Nifty nifty;
private Screen screen;
/*
- Change screen bug with tabs control
*
-
- Change the controller in TabsTest.xml to reflect the correct package (this)
- Change the controller in TabsTest.xml to reflect the correct package (this)
-
- Try out the list boxes in the tabs. They should work ok.
- Try out the list boxes in the tabs. They should work ok.
-
- Click the change screen button.
- Click the change screen button.
-
- Click it again to go back to the first screen.
- Click it again to go back to the first screen.
-
- Note that the tab that was selected before changing screens is now blank.
- Note that the tab that was selected before changing screens is now blank.
-
Changing tabs back and forth shows it again, but now the list box will be irresponsive.<br />
/
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();
guiViewPort.addProcessor(niftyDisplay);
flyCam.setEnabled(false);
nifty.fromXml("Interface/TabsTest.xml", "start");
for(int i = 0; i < 5; i++){
nifty.getScreen("start").findNiftyControl("list1", ListBox.class).addItem("item " + i);
nifty.getScreen("start").findNiftyControl("list2", ListBox.class).addItem("item " + (i+5));
}
}
@Override
public void simpleUpdate(float tpf) {
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
public void bind(Nifty nifty, Screen screen) {
this.nifty = nifty;
this.screen = screen;
}
public void onStartScreen() {
}
public void onEndScreen() {
}
public void changeScreen(String screen){
nifty.gotoScreen(screen);
}[/java]
TabsTest.xml
[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">
<useStyles filename="nifty-default-styles.xml" />
<useControls filename="nifty-default-controls.xml" />
<screen id="start" controller="mygame.Main">
<layer id="layer" backgroundColor="#003f" childLayout="center">
<panel childLayout="vertical">
<control name="button" label="Change Screen">
<interact onClick="changeScreen(screen2)"/>
</control>
<panel id="tabs" childLayout="vertical" align="center" valign="center">
<control id="edit_tabs" name="nifty-tabs" >
<control id="tab_1" name="nifty-tab" caption="tab 1">
<panel id="tab_1_content" childLayout="vertical" align="center" valign="center">
<control name="label" id="label_1" align="left" textHAlign="left" width="100%" text="label 1">
</control>
<control id="list1" name="listBox" width="20%" height="" vertical="optional" horizontal="optional" displayItems="4" selection="Multiple">
</control>
</panel>
</control>
<control id="tab_2" name="nifty-tab" caption="tab 2">
<panel id="tab_2_content" childLayout="vertical" align="center" valign="center">
<control name="label" id="label_2" align="left" textHAlign="left" width="100%" text="label 2">
</control>
<control id="list2" name="listBox" width="20%" height="*" vertical="optional" horizontal="optional" displayItems="4" selection="Multiple">
</control>
</panel>
</control>
</control>
</panel>
</panel>
</layer>
</screen>
<screen id="screen2" controller="mygame.Main">
<layer id="layer" backgroundColor="#003f" childLayout="center">
<panel id="tabs" childLayout="vertical" align="center" valign="center">
<control name="button" label="Change Screen">
<interact onClick="changeScreen(start)"/>
</control>
<control name="label" text="this screen is empty. now go back"/>
</panel>
</layer>
</screen>
</nifty>[/xml]
Any ideas?
Cheers,
Rickard