Niftygui touch event problem? on android

I am experimenting using niftygui in an android app and I am having a problem.



I am using a slightly modified TestNiftyGui.java and hellojme.xml.



I have changed it to have a mouse click on the panel cause a change of the text in the panel.



The mac version does exactly what I would expect, i.e., a click on the panel changes the text.



The android app requires that I do a touch and move into the panel and then touch two more times to get the text to change.



Code is following:

Morris





public class Main extends SimpleApplication implements ScreenController {



private Nifty nifty;



public static void main(String[] args){

Main app = new Main();

app.setPauseOnLostFocus(false);

app.start();

}



public void simpleInitApp()

{

Box b = new Box(Vector3f.ZERO, 1, 1, 1);

Geometry geom = new Geometry(“Box”, b);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setTexture(“m_ColorMap”, assetManager.loadTexture(“Interface/Logo/Monkey.jpg”));

geom.setMaterial(mat);

rootNode.attachChild(geom);



NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,

inputManager,

audioRenderer,

guiViewPort);

nifty = niftyDisplay.getNifty();



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



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

guiViewPort.addProcessor(niftyDisplay);



// disable the fly cam

flyCam.setEnabled(false);

}



public void bind(Nifty nifty, Screen screen)

{

this.nifty = nifty;

Screen myScreen = nifty.getCurrentScreen();

System.out.println("Enter Bind - screen = " + myScreen);

}



public void onStartScreen()

{

System.out.println(“Enter onStartScreen”);

}



public void onEndScreen()

{

System.out.println(“Enter onEndScreen”);

}

public void sayHello(String myarg)

{

System.out.println("Nifty says "+myarg);

Element niftyElement = nifty.getCurrentScreen().findElementByName(“myText”);

niftyElement.getRenderer(TextRenderer.class).setText(“New text”);

}

}






<?xml version="1.0" encoding="UTF-8"?>



















Oops, the xml didn’t show up. What do I have to do to get the xml visible?



Morris

use the java button at the top of the posing gui, and put your code xml whatever there, then it will not be changed.

[java]<?xml version="1.0" encoding="UTF-8"?>

<nifty>

<screen id="start" controller="mygame.Main">

<layer id="layer" backgroundColor="#0000" childLayout="center">

<panel id="panel" height="25%" width="35%" align="center" valign="center" backgroundColor="#f60f" childLayout="center" visibleToMouse="true">

<text id="myText" font="Interface/Fonts/Baskerville25.fnt" color="#000f" text="Menu" align="center" valign="center" />

<interact onClick="sayHello(hi)"/>

</panel>

</layer>

</screen>

</nifty>

[/java]