Nifty tabs problem

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:


  1. Try out the list boxes in the tabs. They should work ok.
  2. Click the change screen button.
  3. Click it again to go back to the first screen.
  4. 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

    *
    1. Change the controller in TabsTest.xml to reflect the correct package (this)
    1. Try out the list boxes in the tabs. They should work ok.
    1. Click the change screen button.
    1. Click it again to go back to the first screen.
    1. 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

1 Like

Excellent testcase rickard! :_)



Unfortunately the original tabs control in Nifty 1.3.1 had several flaws and bugs. It was user contributed and not completely tested. The tabs control has been fixed now for 1.3.2 and was GREATLY improved by another Nifty user, both in stability, API and look and feel.



The only thing that’s missing afaik is to update the documentation in the Wiki for the new and improved Tabs control.



There is no 1.3.2 release date yet but it shouldn’t take too long …



You could try a Nifty nightly build (1.3.2-SNAPSHOT) in the meantime. I’m pretty sure that issue is gone!

Hey.



No, i tried the latest nightly, with the same result. And it’s not only listboxes, all sorts of tab content becomes unresponsive.



Cheers.

I retract my last comment. It’s i who’s not used to the ‘new’ library structure.

I haven’t been able to test it properly yet, however, due to api changes in 1.3.2. Let’s see if i can resolve them.

You need to use the latest nightly NIFTY SNAPSHOT build from the maven repo which might be a bit difficult to use with jme3 right now since it’s not yet available bundled with nightly jme3 builds.



But if you really did see panels that look like that:



http://i.imgur.com/FGfhP.png



and it still didn’t work then please create a bug report at github for Nifty.

(See my last comment)



Sorted out the new libs. Now my tabs are all on top of each other. Guess you can’t have it all :wink: It’s most likely due to my own controls being based off the old ones, though.



Cheers,

Rickard

Slighty OT:

But i have to say, that despite some quirks, that 1.3.2 feels much more solid than the previous versions i’ve used. Several events seem to be handled better and it feels more “ready” in some sense. Performance seems better too so far, but maybe that’s just an illusion. :slight_smile: