Hello,
Im quite new to nifty but i am playing around with the new screenbuilder. Ive made some Buttons and im wondering now how to catch onClick events for them?
[java]NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.loadStyleFile("nifty-default-styles.xml");
nifty.loadControlFile("nifty-default-controls.xml");
Screen MMscreen = new ScreenBuilder("MainMenu") {{
layer(new LayerBuilder("dialogLayer") {{
childLayoutCenter();
panel(new PanelBuilder("dialog-parent"){{
height("200px");
width("200px");
style("nifty-panel");
align(Align.Center);
valign(VAlign.Center);
childLayoutVertical();
control(new ButtonBuilder("SelGrpBt"){{
label("Select Group");
width("120px");
height("40px");
align(Align.Center);
}});
control(new ButtonBuilder("SelDngBt"){{
label("Select Dungeon");
width("120px");
height("40px");
align(Align.Center);
}});
control(new ButtonBuilder("Options"){{
label("Options");
width("120px");
height("40px");
align(Align.Center);
}});
control(new ButtonBuilder("ExitGame"){{
label("Exit Game");
width("120px");
height("40px");
align(Align.Center);
}});
}});
}});
}}.build(nifty);[/java]
Thanks in advance
silent
There is docs on the builders on the nifty wiki, its linked in that tutorial I posted.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui
Edit: Oh using the Builder… Theres setOnAction or something similar… Cant look right now…
Right.
The tutorials are all for the use of XML-Files.
So I guess theres no docs about the use of builder with buttons yet…
Will try a bit around.
You can add this to your ScreenController:
[java]@NiftyEventSubscriber(id="SelGrpBt")
public void onSelGrpBtClicked(final String id, final ButtonClickedEvent event) {
…
}[/java]