I’m making a menu appear when I press a mouse button on something on the scene (using the jme3 default inputManager) and disappear when I release it. The thing is that the menu is a custom lemur container with some buttons. The problem comes when I try to make that buttons fire based on the mouse location when releasing.
The gui can’t know anything about the scene so I can’t make a boolean trick to make it work.
I tried with:
button.addCommands(Button.ButtonAction.Up, new Command<Button>() { ... });
but, obviously, for that first I need the button to be pressed (but there is no way to make it by code or at least I don’t know it. If it were, I could press it on highlight).
The reason the up doesn’t come is because the down doesn’t come (as you’ve discovered) but that’s because the mouse event infrastructure didn’t ‘capture’ the event.
So you coded your own pick infrastructure?
If you uses Lemur’s pick event infrastructure then you at least have some options here. If you register mouse listeners with the various parts then you have some more control over how you handle the events. It’s still a little tricky but it can be done, I think. (For example, if you don’t consume the move events then you will at least get those as you drag around. The mouse release will be delivered to the first component that ‘captured’ it but you can also detect what it’s over at that point.)
this isn’t fully true. Is it normal that if I add that listener to the spatial, the com.jme3.input.controls.ActionListener doesn’t receive the event?, even if it is not consumed by Lemur?.
I’m not sure. It might be that Button automatically consumes some of its events that it delivers to commands. You’d have to do a little digging, I guess… because it’s hard for me to test your situation.
I just found it. What I’m using is a button and the buttons always consume their events (com.simsilica.lemur.Button [243]). I suppose that I should not use a button but create a custom one instead.
Yeah, could be. Note: a button is just a label with built in mouse/command handling. So if you are doing your own mouse handling a label is probably better, I guess.