Changing interectOnClick after .build call

Anyone know if this is possible and how to do it? My attempts thus far have been unsuccessful.

Since there’s no code I don’t know how you’re trying to do this, but the way I do it with XML is like this. IMO it should work, but I don’t use .build except for 1 rare case so I might be wrong.



That piece of code will change a button (Generate Galaxy) to something else (Resume Game) and it’s associated method. Hopefully that’ll work for you.



[java]

if (gState.isGameRunning()) {

// change the onClick method and the name of the New Galaxy

NiftyMethodInvoker onClickMethod = new NiftyMethodInvoker(

nifty,

“resumeGame()”, //NOI18N

nifty.getCurrentScreen().getScreenController());



screen.findElementByName(“mnuGenGalaxy”).getElementInteraction().getPrimary().setOnClickMethod(onClickMethod); //NOI18N

}

[/java]

2 Likes

Thanks, you!