在Display Object类中,除了事件之外,我已经包装了所有内容。我无法弄清楚模式,真的需要一个例子。
在 JavaScript 中,您可以像这样为对象创建回调:
displayObject.onPress = function(event) {
$wnd.alert("object pressed");
}
我已经包装了鼠标事件参数:
public class MouseEventImpl extends JavaScriptObject {
protected MouseEventImpl() {}
public static native MouseEventImpl create(String type, int stageX, int stageY, DisplayObjectImpl target, JavaScriptObject nativeEvent) /*-{
return new $wnd.MouseEvent(type, stageX, stageY, target, nativeEvent);
}-*/;
...other methods excluded...
}
public class MouseEvent {
private MouseEventImpl impl;
public MouseEvent(String type, int stageX, int stageY, DisplayObject target, JavaScriptObject nativeEvent) {
this.impl = MouseEventImpl.create(type, stageX, stageY, target.getOverlay(), nativeEvent);
}
...other methods excluded...
}
显示对象使用相同的覆盖图案。我如何在 java 中编写回调并将其传递给 JSO?如果可以,请提供一个例子。:)