Dynamic positioning of a panel (using NiftyGUI)

Is it possible to move a panel while the application is running? I can’t find any related methods, my attempt to move it with resizing of vertical/horizontal aligned helper panels didn’t work, as my panel ignores that the layout changed and it has to move to fit in again.



Or am I forced to regenerate the gui each time? (I try to build a normal right click menu that should appear where the mouse was clicked).

Nifty layout is always relative to the parent element and the childLayout mechanism you’ve set for the parent. For many child layouts, like “horizontal” or “vertical” it’s not possible to move the elements around freely. What you can do however is to change the constraints of the elements, like the element width or height. The current versions of Nifty won’t apply these changes automatically. So after you’ve changed the element constraints you’ll need to call parentElement.layoutElements() to recalculate the child elements of parentElement.



What you can do to position elements or to move them around in a more freely fashion is to use a childLayout=“absolute” for the parent element or maybe even for another complete layer element. This way the child elements can be moved around by changing the x and y constraints. You’ll still need to call parentElement.layoutElements() or screen.layoutLayers() to apply the changes.

Thank you, that was what I was looking for.

Is there some current documentation for stuff like that somewhere? I could only find “horizontal”, “vertical” and “center” as childlayout in the nifty wiki :frowning:

the 1.2 tutorial demo explained that in detail. you can view that online: http://nifty-gui.lessvoid.com/archives/157