ListBox ScrollBox Not working?

hello

the following code should be working, but once i put user defined components definitions instance inside a scrollbox , it does not render the components correctly


[useStyles filename="nifty-default-styles.xml" /]
    [useControls filename="nifty-default-controls.xml" /]
  
    [controlDefinition name="myControl"]
        [panel childLayout="horizontal" width="200" backgroundColor="#000f"]
          [image width="32px" height="32px" filename="Textures/ground.png"/]
          [control name="label" align="left" text="test" textHAlign="left" height="32px" width="*" /]
           [control id="buttonOk" name="button" label="OK" /]
        [/panel]
    [/controlDefinition]

    [screen id="start" controller="mygame.Main"]
        [layer id="layer" backgroundColor="#0000" childLayout="center"]
            [panel id="panel" width="400" height="300" align="center" valign="center" backgroundColor="#000f" childLayout="vertical" visibleToMouse="true"]
                    
                    [control id="scrollbarPanelId" name="scrollPanel" horizontal="false" height="*" ]
                        [panel id="myScrollStuff" width="500px" height="500px" childLayout="vertical" ]
                            [control name="myControl" /]
                            [control name="myControl" /]
                            [control name="myControl" /]
                            [control name="myControl" /]
                            [control name="myControl" /]
                            [control name="myControl" /]
                        [/panel]    
                    [/control]
                
            [/panel]
        [/layer]
    [/screen]

I tried with a listbox, with and without a ListBoxViewConverter, but compoenetns are never displayed
I spent a week trying to figure this out and i end up wondering if it is stable/working at all
I read on the forum that jme3 did not include the latest nifty gui build

can someone enlight me on this?

thx

ok i managed to make the listbox working , i did not know i could not add items via the xml

but altought i can select items
this code is fired on item selection :

@NiftyEventSubscriber(id="proceduresList")
  public void onMyListBoxSelectionChanged(final String id, final ListBoxSelectionChangedEvent event) {
    List selection = event.getSelection();
    for (ChatEntryModelClass selectedItem : selection) 
    {
      System.out.println("listbox selection [" + selectedItem + "]");
    }
  }

it seems no selection is displayed in the listbox (items dont change colours or something)

so i wanted to change the background color of each items but i cant find a way to do this programaticaly

can someone point me to an example?

thx

i found a way after hours of searching (cfr onCustom tags for thos who are intererested)

but although i could have selected items and focused items on mouse hover
as i do listBox.removeItem(listBox.getFocusItem()); it does not remove the focused item

although the onHover show under the mouse, the second onhover doe not set the item as focused

[controlDefinition name="proceduresListItem" controller="de.lessvoid.nifty.controls.listbox.ListBoxItemController" inputMapping="de.lessvoid.nifty.input.mapping.MenuInputMapping"]
      [interact onClick="listBoxItemClicked()" /]
      [effect]
        [onCustom customKey="select" name="colorBar" color="#ffff" post="false" neverStopRendering="true" timeType="infinite" inset="1px"/]
        [onHover name="colorBar" color="#fff8" post="false" neverStopRendering="true" timeType="infinite" inset="1px"/]
        [onHover name="focus" /]
        [onClick name="focus" targetElement="#parent#parent"/]
      [/effect]
...

plz help me …

anybody ?
is this forum still alive ?

Sorry, I’ve used the combo box but never used the list box so I can’t really help you. Something as simple as removing an item should work though, try separating your call out into two sections (query the focus item, remove it as 2 steps) and breakpoint between so you can see whether it is the query or the removal that is failing.

Also make sure you try/catch/log around it so you can see any exceptions that might be generated.

@zarch said: Sorry, I've used the combo box but never used the list box so I can't really help you. Something as simple as removing an item should work though, try separating your call out into two sections (query the focus item, remove it as 2 steps) and breakpoint between so you can see whether it is the query or the removal that is failing.

Also make sure you try/catch/log around it so you can see any exceptions that might be generated.

well actualy i found a way, but i had to populate buttons dinamicaly in the converter so i could pass id as parameters …

a lot of headache for something so simple, nifty has a lot of great features, but lacks of obvious simple stuf depending on what we need

thx anyway for you answer

@curtisnewton said: well actualy i found a way, but i had to populate buttons dinamicaly in the converter so i could pass id as parameters ...

a lot of headache for something so simple, nifty has a lot of great features, but lacks of obvious simple stuf depending on what we need

thx anyway for you answer

That’s exactly the reason why Chris made t0neg0d GUI.

@madjack said: That's exactly the reason why Chris made t0neg0d GUI.

cant find any link, is there a web site ? is it stable ? is it hard to interface/implement with jme ?

The forum is at http://hub.jmonkeyengine.org/forum/board/projects/tonegodgui/
It’s work in progress, but advancing quickly - early beta, I’d say.
Follows Nifty concepts in some areas. Uses the JME scene graph but mostly hides it (which has advantages and disadvantages).
It does have its quirks (already, as does any GUI library).
Chris is enthusiast, still learning, so the occasional architectural glitch can and does happen. She’s getting lots of advice, so most problems get cleaned out.
Enthusiastic user base.

Then there’s Lemur, http://hub.jmonkeyengine.org/forum/topic/lemur-work-in-progress-posted/
Designed to be lean; leverages JME’s scene graph very visibly. Not very polished, which shows in missing functionality, lack of docs - let’s say, mid-alpha for general use, production quality if you happen to need just what the author (Paul) needs. Very small, so it’s easy to find out how things work.
No real quirks. Bugs get fixed real quick, despite Paul not having much time for it.
Paul is a seasoned professional. Chances are that any quirks that you notice are already on his To-Do list.
Small user base.

1 Like

Excellent summary @toolforger