Layers on Nifty Popup?

Hi All,



I am using popups for a menu system, however I am having some trouble setting up the layout. This is what I am trying to achieve ( green and red arrows are nifty moveEffects on open and close )







I am using a center layout for the popup since this make positioning panel01 ( The main panel ) straight forward. Panel02 would be align=“right” valign=“center”



[xml]

<popup id=“popup” childLayout=“center” >

<panel id=“panel01” backgroundColor="#000f" align=“center” valign=“bottom” childLayout=“vertical” >

<!-- Contents here -->

</panel>

</popup>

[/xml]



As other users of Nifty will know, using 2 elements on a “center” layout does not work, and is not intended to work. So I tried to add layers to my popup in order to apply the two panels to individual layers, like this:

[xml]

<popup id=“popup” childLayout=“center” >

<layer id=layer01>

<panel id=“panel01” backgroundColor="#000f" align=“center” valign=“bottom” childLayout=“vertical” >

<!-- Contents here -->

</panel>

</layer>



<layer id=layer02>

<panel id=“panel02” backgroundColor="#000f" align=“right” valign=“center” childLayout=“vertical” >

<!-- Contents here -->

</panel>

</layer>

</popup>

[/xml]



However when I do that I can no longer retreive panel01 and panel02 from Java, like this:

[java]

Element panel01 = popup.findElementByName(“panel01”);

Element panel02 = popup.findElementByName(“panel02”);

[/java]

It simply returns a null pointer…



I also tried an alternative approach where panel01 is on one popup and panel02 is on another popup, both will be triggered at the same time, but this causes a series of problems with the moveEffect where the end of an effect on one popup causes the effect on the other popup to cancel ( causing the main popup to never close… )



Anyone has an idea how to solve this?

Well you named them panel01 in the XML and popup01 in your Java…

Oh yes, please ignore that I changed the names to make it shorter and easier to understand… I’ll just rectify that in my example here. Just like [xml]<!-- Content here -->[/xml] Is actually full of panels n stuff.

Honestly I don’t use nifty popups so I can’t be a big help. You could just place the panels in your main screen though and then use a custom effect to bring them on/send them off screen when needed - rather than using popups at all.



What I can say is (assuming the names are right) then so far as I know findElementByName should work…it always has for me (but as mentioned above - I don’t use popups).

As other users of Nifty will know, using 2 elements on a “center” layout does not work, and is not intended to work.


That has been fixed with Nifty 1.3.1 iirc. To quote from Nifty Manual Page 54: "Another thing that has been improved in Nifty 1.3.1 is that childLayout=“center“ now supports more than one child element! In versions prior 1.3.1 childLayout=“center“ would only support a single child elements and odd things would happen to the other elements. This has now been improved as well and childLayout=“center“ supports more than one child element."

:)

So I tried to add layers to my popup in order to apply the two panels to individual layers, like this:


Popups don't support layers at all I think. A popup in Nifty is treated as a Layer already. I don't think this is valid XML according to Niftys XSD. Can you check? Nifty will try to read that but it will fail which would explain why you can't access the elements anymore :)