Hi there,
I'm still a bit green myself so not sure how much help i can be, but here goes…
In you controller class that you have defined for the screen ("rpgjme3.ScreenContGUI"), do you actually have a method called "quit()" ?
Can you post your code for the controller?
Not really it can be any thing as long it matches the xml and the controller class file. But ti took a while to find it. It was in the svn and hard to look deeper in it since the xml format tricky a bit.
ScreenContGUI.java
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
public class ScreenContGUI implements ScreenController {
public String test;
/** nifty instance. */
private Nifty nifty;
/**
* Bind this ScreenController to a screen.
* @param newNifty nifty
* @param newScreen screen
*/
public final void bind(final Nifty newNifty, final Screen newScreen) {
this.nifty = newNifty;
}
/**
* on start screen interactive.
*/
public final void onStartScreen() {
}
/**
* on end screen.
*/
public final void onEndScreen() {
}
/**
* quit method called from the niftygui04.xml.
*/
public final void quit() {//create a trigger in the xml to exeute it
//nifty.setAlternateKeyForNextLoadXml("fade");
//nifty.fromXml("all/intro.xml", "menu");
System.out.print("quit" + "n");
System.out.print(test + "n");
}
}
Here the example of it.
ScreenContGUI.java
...
public final void clickme() {}
...
niftygui.xml
...
<interact onClick="clickme()"/>
...
Is that code copied and pasted from something that you have working already? I only ask as the quit method wouldn't compile as there are no quotes around the "test" in the last System.out.print line…
In principle all the pieces of the jigsaw seem to be there, so the devil must be in the detail (which is harder to troubleshoot without seeing your actual code)
What IDE are you using? do you get an output message along these lines when you perform a click action?
de.lessvoid.nifty.NiftyMethodInvoker performInvoke
WARNING: invoke for method [textClick()] failed
Well the code that use from jmonkeyengine google code. It was in the svn in jme3test folder.
Here the link:
http://jmonkeyengine.googlecode.com/svn/branches/jme3/src/test/jme3test/niftygui/TestNiftyGui.java
Just make sure the ID tag matches. Those I post for the code that was the test just for nifty gui build. If you having trouble just paste your code sample it easy to under what going on. I pretty new at the format base. I am using eclipse IDE.
I think we may be talking at cross purposes here… I have been experimenting with Nifty and I already have a controller class that I have written connected to a gui that I have created and the methods called by the onClick events within the GUI correctly trigger the expected methods within the controller class.
I was asking to see the code that you are trying to make work so that I could (hopefully) either steer you in the right direction or spot the bug that was causing your onClick actions to fail, since you original post said:
I need some help with this. I am trying to trigger an event to just one of the button. I am trying to create a GUI game format. I want to make is handle game items and data when the button is press.
Can I assume that from your original post that you have an instance of JME3Nifty.java in your project, and that when you run it the niftygui.xml file that you have created is correctly loaded and displayed on screen with all the move / pulsate effects functioning as expected?
If that is the case, the issue is most likely in your controller class ("rpgjme3.ScreenContGUI") that you reference from your niftygui.xml file. Can you post the contents of that file?
Regardless of if you can / can't / will / won't post the code ( please help me to help you! :) ) you can test to see if your controller is being called by nifty by adding some debug to the onStartScreen and onEndScreen methods within your controller class. If your controller contains the following method:
public void onStartScreen() {
System.err.println("now in onStartScreen - controller must be bound to gui");
}
and you do not see that output when your gui loads, your controller class is not being located correctly.
There are probably far better ways of testing if the gui has bound to the controller - but this works for me, and I am still learning the dark arts of Nifty so I think I should be let off :)
I had my package setup to deal with the path and package.
Here the simple version that is strip down so simple to do. This is from eclipse IDE build.
It took a while to find those code to make them work.