我无法让我的自定义控件通过交互onClick="next()“属性调用函数。我试图将"next()“函数同时放在我的screenController和buttonController上,但是仍然没有结果.我肯定错过了一些简单的东西..。
以下是我的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扩展屏幕实现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!");
}}
发布于 2014-07-25 20:21:36
控件中的图像将消耗鼠标事件,因为它们位于控制面板的顶部。在这种情况下,添加到面板中的任何交互都不会接收鼠标事件。您将需要删除图像或使其visibleToMouse=“假”。目前你不能两者兼得。
https://stackoverflow.com/questions/24961993
复制相似问题