Nifty eventbus: event consuming when gotoscreen


I already used nifty with slick it works great!

Here i want a panel with some buttons (

The first button switches the set of buttons shown (

For this purpose i created two screens, with the same layer/panel layouts.

I registered the first button to event bus as follow :

[java] @NiftyEventSubscriber(id = "switchButton")

public void onSwitchButtonClicked(final String id, final ButtonClickedEvent event) {

String curScreen = nifty.getCurrentScreen().getScreenId();

if (curScreen.equals("mapedit")) {


} else {




This works fine, except that the input event seems to be sent to the game. If I remove the gotoscreen calls, there is no issue.

Probably you call the methods from another thread (the slick input or update thread?).

Here im working with jme3. I didn’t run any other thread myself. I only have the 3 threads LWJGL rendering, audio and timer.

Okay, try enqueueing the call to gotoscreen anyway then. Thing might be that due to the change in screen the layout after that is checked for the mouse being “caught” by the UI.

That is also what i was thinking…

However, i expected to know about some way to consume an event, so that it is not used by any other listener.

The method Nifty.resetMouseInputEvents() doesn’t help in this case, I’d be glad to know its purpose

I guess it clears the queue of nifty… Maybe @void256 can tell you more.

@cghislai hey, I just want to take a chance and ask you something. I understand that with, “@NiftyEventSubscriber(id = “switchButton”)” you register the following method with that button, but how do you know how_to_name_the_method , so it works. Its like, after using the annotation, I dont understand what method I should call. I don’t even know where to look for a list of all possible methods. Thanks in advanced.

@iamcreasy: I think you can name the method whatever you like. Just add the annotation and it will be registered to the control. You can check the events sent by controls on the nifty controls page:


I found out the cause of this issue. Nifty was conuming mousePressed events, but i was still receiving mouse button up ones.

My code was not able to handle mouse up events correctly. It’s all fixed now.

No gotoscreen delaying is required