Hiding element in nifty gui

is it possible to hide an element and have its siblings flow to take its place?
i have tried
someElement.setVisible(false);
someElement.getParent().layoutElements();
but it did not produced desired effect (there is still empty space where the element was)
is this even the correct way to do it?

Hiding it doesn’t remove it from the screen graph. I would remove the elements and add them back in later.

1 Like

thank you, got it working with
Nifty.removeElement(Screen screen, Element element)
although i’m questioning what is the purpose of Element.markForRemoval() other than to rip your head off in despair, because i could not get it to work without causing an exception nor could i find a workig example how to use it.

markForRemoval() is the correct way to do it. What is the exception you get?

1 Like

WARNING: Root Cause: java.lang.NullPointerException
Feb 05, 2015 2:26:22 AM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.elements.Element onEndScreen (Element.java:2280)

nifty 1.3

You need the full stack trace. What element are you trying to remove?

I finally managed to figure it out. I was using Nifty.gotoScreen(String id) AND Element.markForRemoval() in the same non concurrent code block witch was invoked by onClick event.

Since i wanted to modify gui when moving between screens, i moved Element.markForRemoval() to ScreenController.bind(Nifty nifty, Screen screen) and everything works fine.