Problem Nifty mouse interaction

Hello every body!



I’m a new user of JMonkey Alpha 4 and I try to create a menu with Nifty. Every thing was okay but I have a problem to get the mouse events.



I add an interact element in my xml file to call a Java function but nothing is done…



My xml file :



[xml]<screen id=“start” controller=“mygame.Menu”>

<layer id=“firstLayer” childLayout=“center” backgroundColor="#003f">

<panel id=“firstPanelParent” width=“100%” height=“200” backgroundColor="#ff000000" childLayout=“vertical” valign=“center”>

<panel id=“firstPanel1” width=“100%” height=“10” childLayout=“center” />

<panel id=“firstPanel2” width =“100%” height=“50” backgroundColor="#002a" childLayout=“center” >

<effect>

<onStartScreen name=“move” mode=“in” direction=“top” length=“1000” startDelay=“0” inherit=“true”/>

</effect>

<text font=“Interface/fonts/default.fnt” text=“Commencer une nouvelle partie” align=“center” valign=“center” />

<interact onClick=“sayHello()”/>

</panel>

<panel id=“firstPanel3” width=“100%” height=“10” childLayout=“center” />

<panel id=“firstPanel4” width =“100%” height=“50” backgroundColor="#002a" childLayout=“center”>

<text font=“Interface/fonts/default.fnt” text=“Quitter” align=“center” valign=“center” />

</panel>

</panel>

</layer>

</screen>[/xml]



And my Java class :



[java]public class Menu implements ScreenController {



Main main;

private Nifty nifty;



public Menu(Main main) {

this.main = main;

this.initMenu();

}



public void initMenu() {



NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(main.getAssetManager(),

main.getInputManager(),

main.getAudioRender(),

main.getGuiViewPort());





nifty = niftyDisplay.getNifty();

nifty.fromXml(“Interface/menu.xml”, “start”);



// attach the nifty display to the gui view port as a processor

main.getGuiViewPort().addProcessor(niftyDisplay);

main.getFlyCam().setDragToRotate(true);

}



public void bind(Nifty nifty, Screen screen) {



}



public void onStartScreen() {



}



public void onEndScreen() { }



public void sayHello() {

System.out.println(“COUCOU”);

}

}[/java]



Thank you very much for your help :slight_smile:

Hi,



I have this problem aswell for a week already…





Cheers

Okay so after many try I found the problem :slight_smile:



The initMenu() function hasn’t to be write in the controller class. It seems to create some conflicts…



Cheers