Is there builtin listener to detect panel detach?



Is there builtin listener to notified on Panel detached from scene graph in Lemur ?

I have a ViewPortPanel which extends Lemur Panel. I want to detect when panel attached/detached to create/clean up viewport. As you know when a spatial detached all controls on it stop being updated so there won’t be a way to detect it internally.
At the moment my ViewPortPanel uses a control added to root node to detect on attach/detach. I am curious if there is a better way ?

Is there a builtin mechanism for this in Lemur ?


Lemur can’t know this… even JME doesn’t know this.

The question is: “When is this Spatial no longer associated with any ViewPorts?” It could be in 0 ViewPorts…it could be in 100 ViewPorts… there is no way of knowing.


But the real question is: “When does your app not know when it’s detaching it’s spatials?”

ie: why can’t it runEffect(close) on that panel when it removes it?


Okay, thanks for quick reply. Actually the ViewPortPanel is someone else code and he is using a control on root node to do viewport setup/cleanup but I am not happy with this approach.

I had forgotten about using effects. Going to try it, thanks.


And by the way, things like the pop-up state will already be running EFFECT_OPEN and EFFECT_CLOSE for you… just FYI.


I guess you are using my code. That approach has worked for me very well. It was the better way I could find to handle this listening properly, as the problem is not just that the spatial is being attached/detached itself but that any ancestor can be attached/detached.
As for the question:

My solution was to assume the general case. The spatials get updated in a single-threaded fashion
(otherwise is jme who crashes anyway) and there is no viewport contemplation at all (it can be in as many viewports you want). If they stop being updated, but their ancestor root continues, it is assumed to be detached.

It may not be the ideal solution, but so far it works, and it works as simple as adding a control to the spatial you want to monitor.