Hello!
I’m just posting this (bug?) issue in this forum again (have originally posted it here) mainly to its strong relation and for the sake of other developers who might come across it. I know it’s a Nifty GUI bug but I hope some of the gurus here could/would be interested to look at it.
I’m using nifty 1.3.1 with jme3 inside an eclipse plugin for software visualization. I was trying to use the TreeBox control to display some items but unfortunately I soon realized that this particular control seems not to be fully implemented yet? Or is what I’m facing are bugs? So here is what I’m facing…
1)TreeItemSelectedEvent is not published at all!! Instead, a ListBoxSelectionChangedEvent is being published which is apparently a result of the the treeBox being internally represented as a ListBox. But still, this should not be the case. The correct event should be published I suppose.
2)Moreover, I found out that nifty behind the scenes adds the following property [onClick=“listBoxItemClicked()”] for each ListBoxItem created (what should have actually been aTreeItem ) and yet, this is not mentioned anywhere in documentation.
3)More importantly, the onListBoxSelectionChanged() method of the TreeBoxControl is actually never called!! This is where the collapse & expand stuff is implemented so without it, the tree items are not collapsible/expandable upon clicking!! I had to catch the ListBoxSelectionChangedEvent and then work my way to force call the onListBoxSelectionChanged() method on the TreeBoxControl which then also results in triggering the TreeItemSelectedEvent !!
Now after the above hack is put in place, the situation is somewhat better but the following problems are still faced:
4) The first node gets always selected, even after the use click on another item!! As soon as that item is selected, the event is generate for that item and then apparently the whole tree structure gets rebuilt which makes the first node becoming selected back again!!
5) The TreeItems are no longer getting highlighted (text getting yellow color)
6) More importantly, now I have to double click an item to get it collapsed/expanded!
I know this is probably too much for a single post but I’m really keen to get this working as I’m developing a tool for my master’s thesis and I don’t want to resort to less exciting solution. I would really appreciate if this bug could be solved quickly or at least someone helps me on how I can best resolve the problems above, especially 4 and 6.
Thank you very much.
Mujtaba
_________________________
Some console output is below in case it helps. Please note that I’m only creating a TreeBox control and not a ListBox !!
_________________
TreeBox xml definition:
_____________________
and finally, the event handling method:
TreeEntryModelClass selectedItem = (TreeEntryModelClass)event.getSelection().get(0);
TreeItem item = selectedItem.getTreeItem();
/**
* This is a temp hack to invoke the internal event method of TreeBox and
* we are doing it because currently as of Nifty GUI 1.3.1 this method is
* not being called anywhere.
*/
TreeBoxControl treeBoxControl = (TreeBoxControl)nifty.getScreen("start").findNiftyControl("scrumsTree", TreeBox.class);
treeBoxControl.onListBoxSelectionChanged(id, event); // This method should have been called internally by Nifty, right?
System.out.println("Item Selected value is: "+item.getValue());
System.out.println("ListBoxSelectionEvent is published with id: "+ id);
System.out.println("Item Selected is: "+event.getSelection().get(0));
}</div>