JSNI 機能を使用して、同じ非常に便利な Canvas および Animation ライブラリを GWT に移植しています。私がラップする最初のライブラリであるため、この特定のコンストラクターで少し支援を使用できます。
/**
* This is passed as the parameter to onPress, onMouseMove, onMouseUp, onMouseDown, and onClick handlers on
* DisplayObject instances.
* By default, mouse events are disabled for performance reasons. In order to enabled them for a specified stage
* set mouseEventsEnabled to true on your stage instance.
* @class MouseEvent
* @constructor
* @param {String} type The event type.
* @param {Number} stageX The mouseX position relative to the stage.
* @param {Number} stageY The mouseY position relative to the stage.
* @param {DisplayObject} target The display object this event relates to.
* @param {MouseEvent} nativeEvent The native DOM event related to this mouse event.
**/
var MouseEvent = function(type, stageX, stageY, target, nativeEvent) {
this.initialize(type, stageX, stageY, target, nativeEvent);
}
var p = MouseEvent.prototype;
ここでクラス全体を表示できます: http://easeljs.com/docs/MouseEvent.js.html
私の質問は、GWT からイベントを渡し、このクラスの JSNI コンストラクターに正常にフィードするにはどうすればよいですか?
参考: Easeljs (0.2.1) の Timknip の GWT ポートをフォークし、最新の Easel 機能 (0.4.0) を含めるように更新しています。https://github.com/timknip/easel-gwt
EDIT:ネイティブイベントは、あなたがJavaで書いた関数だと思いますよね?キャンバスのどこかをクリックしたときに ONMOUSEUP イベントを追加し、そのロジックが "onClickSomeButton()" という名前の関数に保持されている場合、このメソッドをこのコンストラクターのパラメーターとして渡したいとしますか? Java がメソッドをパラメーターとして渡すことはできないと思いますが、抽象 GWT クラスを拡張してこれをラップする方法はありませんか?