我无法让我的自定义控件通过交互 onClick="next()" 属性调用函数。我试图在我的 screenController 和我的 buttonController 上都放置“next()”函数,但仍然没有结果......我必须在这里遗漏一些简单的东西......
这是我的 CustomControl 定义:
<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>
这是屏幕 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>
这是屏幕控制器:
公共类 ScreenJME 扩展 Screen 实现 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!");
}
}