Mouse events are consumed by the programme before Nifty can read them

Hey everyone,

I am quite new at using LWJGL and Nifty in Java and it is my first post here. So hello together and thank you already for the help you provided in so many threads I have been reading without contributing yet :smile:

I have a problem concerning mouse events using Nifty. I have a nifty .xml containing some panels and controls and a code that at one point in my getInput() function implements a
while( …
loop. Within that while loop, pressing and releasing mouse buttons leads to several programme functions.

My problem is, now, that any event (mouse press or release) is consumed by that loop. I cannot access any nifty elements, because nifty.update() is run after my getInput() function.

If I change my while-loop to a simpler
if(Mouse.isButtonDown(0)) …
nifty and programme controls work fine, except that I just need one click considererd making the while-event-loop a perfect choice.

If I swith the order of functions (nifty.update() before getInput()) the problem turns out to be the other way round (nifty consumes events).

I don’t know if you would need any code to help me, but in general, how can I achieve that any click is consumed by a nifty control if it needs to (moue over it) and that it does not when it mustn’t? I read about nifty consuming events already, but this problem seems to be slightly different to me.

Thank you very much, I really appreciate your help!

Why are you using This is LWJGL API. You’re essentially taking away all the input events before jME3 can use them.
You should use the InputManager API to access input, this also integrates directly with NiftyGUI, so you only get events that have not been handled by it.

Wait… are you actually using jMonkeyEngine or did you post this question to the wrong forum?