Nifty button control not works

Hello!



I started to write an application, for now it is only a gui which i struggle to make working. I cannot make my button work, the button is visible and visually responds to mouse click.



I made this control element visibleToMouse=true, i have a screen controller object that has the methon i would like to invoke login().



my files: https://gist.github.com/3359285



thanks in advance

Try to define the screenController in a separate class and attach it at the screen.tag in your xml. This is also recommended 'cause ScreenController normally grow very fast.



[xml] <screen id=“login” controller=“org.caster.client.ScreenController” >[/xml] (currently not sure about the attribut-name. Maybe it’s screenController)

If you want proper troubleshooting you’ll need to provide the gui’s XML.

@madjack: he has. It’s under the java-file.

wtf!? It wasn’t there when I looked. O_o

Just curious. Do you get output if you put a println in the screen controller’s bind method?



One way or the other, you need a screen controller defined in your screen’s XML (as ceiphren mentioned). That’s how nifty knows where the methods in your XML are to be called.



Oh and btw, don’t use the same id in the layer and the screen. Not a good idea. IDs should be different. Also, it’s not a necessity to id every elements. Only those you need to call (or controls with interaction).

Thank you guys for a quick answer, i’ll try what you said in a minute

Do you get output if you put a println in the screen controller’s bind method?


Nope, it doesn't. I suppose it shoud. So the problem is that my controller is not bind. I'll try to bind it via xml

I made controller in a separate class. Still doesn’t work.



And when I made binding through xml i started to work. So the statement:

[java]

nifty.fromXml(“gui/gui.xml”, “login”, controller);

[/java]



doesn’t actually bind “controller” to “login” screen. Am i right?