I can't get my custom control to call a function through the interact onClick="next()" attributes. I tried to put the "next()" function on both my screenController and my buttonController but still, no result... I must be missing something simple here...
Here is my CustomControl definition:
<nifty-controls xmlns="http://nifty-gui.lessvoid.com/nifty-gui">
<controlDefinition name="customImage-button" style="nifty-panel-style" controller="com.certification.renderer.jme3.gui.customControls.imagebutton.ImageButtonControl">
<panel style="#panel" childLayout="overlay" focusable="true" width="$width" heigth="$height">
<image id="#clicked" name="image-1" style="#select" filename="$img1" visibleToMouse="true" filter="true" >
<interact onClickRepeat="pressedButton()" onRelease="releaseButton()" />
</image>
<image id="#uncliked" name="image-2" style="#select" filename="$img2" visibleToMouse="true" filter="true">
<interact onClickRepeat="pressedButton()" onRelease="releaseButton()" />
</image>
</panel>
</controlDefinition>
</nifty-controls>
Here is the screen XML:
<nifty>
<useStyles filename="nifty-default-styles.xml" />
<useControls filename="Interface/custom-controls.xml" />
<screen id="loginScreen" controller="com.certification.renderer.jme3.gui.ScreenJME">
<layer id="layer3" childLayout="center">
<control id="numpadnumber-1" style="numpad" name="customImage-button" width="13%" height="11.75%"
img1="Interface/images/1_numpad_clicked.png" img2="Interface/images/1_numpad.png"
controller="com.certification.renderer.jme3.gui.customControls.imagebutton.ImageButtonControl"
visibleToMouse="true">
<effect>
<onClick name="fade" start="#f" end="#0" length="15000" />
</effect>
</control>
</layer>
</screen>
</nifty>
Here is the screen controller:
public class ScreenJME extends Screen implements ScreenController {
protected String _path;
private String _key;
protected Nifty _nifty;
protected Application _app;
protected de.lessvoid.nifty.screen.Screen _screen;
private String password = "";
private final float screenHeight = 1050;
ScreenJME()
{
//EMPTY
}
ScreenJME(String path, String key, Nifty nifty)
{
_path = path;
_key = key;
_nifty = nifty;
}
@Override
public void bind(Nifty nifty, de.lessvoid.nifty.screen.Screen screen)
{
this._nifty = nifty;
this._screen = screen;
System.out.println("Binding...");
}
@Override
public void onStartScreen()
{
switch (_key)
{
case ("loginScreensss"):
// populate();
break;
default:
break;
}
System.out.println("onStartScreen..");
}
@Override
public void onEndScreen()
{
System.out.println("..onEndScreen");
}
(...)
public void next()
{
System.out.println("next() clicked! woohoo!");
}
}
The images in your control will consume the mouse events since they are on top of the control panel. Any interact added to the panel will not receive mouse events in that case. You'll need to remove the images or make them visibleToMouse="false". Currently you can't have both.