Lemur mouse click in scene outside of spatial question

This might have been answer in the past and if so I apologize in advance. I need to somehow register a listener in Lemur so that if the user clicks in the scene outside of any spatial I can fire the listener. Any way to achieve this with Lemur?

Not sure what you realy want or need. In/with lemur you can add a listener to any spatial.
Otherwise you can register a JME standard Actionlistener and define if mouse clicked + any condition then do something. JME picking
If the click must be somehow inside a specific area you might add an aditional lemur element/spatial, place it and attach a listener to that.

I use Lemur to select spatials. Once selected a popup menu of options appears. I want to hide the popup if I click outside the popup in any area of the screen that does not contain a spacial with a lemur mouse listener.

Looking at the source, lemur adds a CursorEventControl, so if doesnt have one of those it can’t have an event listener.

Yup I saw that … I was just wondering if there was another facility to “unpick” by clicking outside the Spatial that has a registered Cursor Event.

I would set a variable once the popup is opened. Then you might add a standard JME mouselistener/clicklistener and check if this variable is set.

Maybe, but I am not sure about that, you can use the lemur PopupState ??

getState(PopupState.class).showPopup(yourspatial,PopupState.ClickMode...,commandwhenclosed)

Why not just use the existing pop-up stuff which will automatically close the pop-up when you click outside it?

…which is what Aufricer is mentioning. There are examples of it in the Lemur Demo.

Because the popup menu is a JavaFX animated radial menu :wink:

I may repeat myself but you may by clicking save a variable that holds an info about what menu (id/spatial id) was opened. You also may set a boolean menuopen=true. With a standard mouseclick you check if menuopen = true. If not you did not open a menu with that click. Then you know that you need to close all open menu. At the end you set menuopen = false. You can even make this tome dependend.
Of course you need to work that out a bit e.g. what if you (want to) open 2 menu at once or open a new one and close the one already open etc.
If you have a solution it would be nice from you to share the code snippet (i will need a popup menu like that too, sooner or later).

But if you pop-up an empty panel… then anywhere you click on screen can be intercepted with a close action.

I ended up doing that last night. Sucks that we don’t have a catch all callback in Lemur so that it can be called if Lemur does not find a target though.

Many scenes have a skybox, etc. so adding a listener to the root node is enough.

In other cases, it can be hard to know how many layers there are, event handling states, etc…

I mean, I suppose there could be a “this didn’t hit anything” callback you could register with each of the various cursor handling app states and then be blasted by every little mouse move, etc… Let the user manage it how they’ve setup their scene.

It just seems like the alternatives have never been too onerous.