this line:
[java]nifty.getScreen("start").findElementByName("window").setVisible(false);[/java]
you don't have an element with id window? and also that if setEnabled(true) is called more than once, than you would add the processor again (not sure if its actually an issue tho)
also make sure that everything is how it should be with [java]nifty.setDebugOptionPanelColors(true);[/java]
I personally use JavaBuilders, but it won’t be different with XML. Here’s what may be the problem (and poo to me if someone already mentioned this)
You have the MyScreenControllerClass which implements ScreenController. This gives you a method called bind(Nifty nifty, Screen screen). In this method, call the following:
[java]
Element button1 = nifty.getScreen(“Whatever your screen ID is”).findElementByName(“Whatever your button ID is”);
//then down below you can do button1.setEnabled(true); or whatever else you want to do.
[/java]
That’s not a 100% guarantee that’s the problem, but trying to bind it could help.
You could also try adding a String resource to your startPressed() method, so it’s like the following:
[java]
public void startPressed(String confirmation) {
System.out.println(confirmation);
}
[/java]
And in the XML:
[xml]
<interact onClick=“startPressed(Button1)”/>
[/xml]
Or button3 for that confirmation string, or however you want to do it so you can see if it’s just a specific button or all of them. Hope that helped!
I do have window, i just updated the XML sorry don’t know why that wasn’t in the code originally, but err, why do i need to add Button1 to to that method call?
@jmaasing but I used your code, after expanding upon it and what is supposed to happen? the method does not appear to be called. In my project, I have found that when I make a window it cannot be dragged around at all, adding this to the button problem I am now convinced that this is a bug because I really cant find any error with my code, and I’ve been staring at it for over a week now. I also tested it on a different pc with eclipse and the latest nightly (I use stable and JMP at home).
If anyone is willing, I can upload the latest version of my code to be tested…
Write a new SimpleApplication. It shouldn’t have to be more than the main class, boil down your problem to as few lines of code as you can.
Try to use existing resources in jme-test-data or make a minimal nifty.xml. Paste the code in code tags here. That’s probably the best way to get people to look at it.
I think most devs. don’t have the time to download some zip-file, unpack it, import et c. so you probably won’t get anyone to look at it then.
That will not be possible, as it works when run from just the main class, its only in a separate App State that I get a problem. I have been reading up a bit more on App States, I’ll try out some more thing then come back when I’ve had another shot at debugging it
Oh god, I found out that I wasn’t passing the Input Manager from main to my app state, that took over a week out of my project, thanks for your patience. I spent soo long trying to debug this feels great now to have it finally working.