[SOLVED]onClick interaction



<control width=“25%” name=“button” label=“Ok” align=“center” color="#000f">

<interact onClick=“enter()”/>



That is the way I want to make my button start the game.

The ScreenController is set:


<screen id=“NameScreen” controller=“mygame.Game”>


And in the Game class, there is a method called:


public void enter()


It initializes the keys and so on.

But nothing happens when I click that button.

I already tried to solve the problem by usen onRelease but nothing happened.

I did everything step by step like in the tutorials.

The only thing that seems to be unusual is that the button stays “being pressed”

So after I released it it doesn’t have it’s normal color.

I don’t really know how to explain that (fighting with my english), but when I clicked it once, and realeased it, the button still looks like it would still be pressed…



After releasing:


Thanks for the tipp, it’s working now, BUT: how do I remove that nifty GUI?

I tried the exit() method and to remove the screen, but as I read here:


That caused troubles before trying to switch screens.

The exit() method or



does not work.


registered the ScreenController before loading xml file.



nifty.fromXml(“Interface/NameScreen.xml”, “NameScreen”);


Did you register the screen controller with nifty?

Has your screen controller implemented the screen controller interface?

Do you get any warnings etc in the logging?

1 Like

That looks right :slight_smile: