[SOLVED] Action Listener ignores mouse events when cursor is set to visible

I am trying to catch click events using an ActionListener, specifically for use in a Lemur interface. (I have a drop own control that needs to be detached when the user clicks anywhere, and there are many other containers also catching clicks, so I cannot manage to do this with a single lemur mouse listener attached to a panel in the background).

In the process of doing this, I noticed that the standard ActionListener ignores MouseTriggers if you set the cursor to be visible with inputManager.setCursorVisible(true)

Is this intended to work this way? And if so does anyone have any suggested workarounds?

Thanks :slightly_smiling_face:

The feature is intentional. In Maud, I worked around it by going direct to LWJGL:

import org.lwjgl.input.Mouse;
float dx = Mouse.getDX();
float dy = Mouse.getDY();
1 Like

Thanks! I did not know about that class before, but it looks quite useful. I looked over the javadoc and also found the Mouse.isButtonDown(int button) method, so everything is working now.

I appreciate the help! :smiley:

You should be able to set one invisible panel in the background of everything in the guiNode… it will catch all of the clicks that don’t get grabbed by something else.

Unfortunately in this situation there are lots of other containers in the same interface that are also catching clicks, so It left many unrelated Containers where I could click without it being caught by the invisible background container.

Wait… why isn’t the drop down control just a popup? I misread your post originally.

This is precisely what the popup stuff is for. Show a window on top of everything else, detach it when somewhere else is clicked.

1 Like

I did not know that a Popup already existed, and made a custom DropDownContainer class that extends Container, but it sounds like I may have reinvented the wheel in a worse way haha.

Do you have a link to an example using a popup in JME? I’m having trouble finding it with a google search for some reason. Is it a lemur speific class?

You can run the demo to see the different modalities.

1 Like

Can this be used to translate the x-y into world coordinates given the camera rotation and an intersecting plane ?

I mean, I guess… but what is it that you are actually trying to do? Because you could also place a cull always quad in the scene itself and get actual coordinates with a cursor listener.

Edit: but yes, if you put a screen size quad in the background of the GUI node then you can get x,y from the cursor listener on that quad. Just be careful what you consume if you also want the 3D scene to have picking.

Doing that now. Until writing this, I didnt think to be able to move that around depending on where the camera is looking.