2

カスタムハンドラーに渡されるtapEventオブジェクトからタップ座標を取得する方法を見つけるのに苦労しています(とにかく仕様が見つかりませんでした)。カスタム変数「X」を座標である「Y」として渡すsingleTapイベントもありますが、エミュレーターでそれを呼び出すことはできません。

ポイントは、大きな要素があり、ユーザーがタップした場所を正確に知る必要がある1つのアプリケーションで作業していることです(おそらくグローバルスクリーン座標または要素の相対座標)。

コード例は次のとおりです。

//inside of assistant's setup method:
Mojo.Event.listen(this.controller.get('elem'), Mojo.Event.tap, this.listenSingleTap.bindAsEventListener(this));

//custom handler:
SomeAssistant.prototype.listenSingleTap = function(singleTapEvent){
    this.someOtherMethod(singleTapEvent.x, singleTapEvent.y); //This is wrong and doesn't work - how I suppose to get tap coordinates?
}

ご提案いただきありがとうございます。

4

1 に答える 1

4

タップ イベントの x 座標と y 座標は、イベントの "down" プロパティにあります。

元。

MyAssistant.prototype.setup = function() {
    Mojo.Event.listen(this.controller.get('elem'), Mojo.Event.tap, this.handleTap.bind(this));
}

MyAssistant.prototype.handleTap = function(event) { 
    Mojo.Log.info("tap down at x: " + event.down.x + " y: " + event.down.y);
}
于 2009-09-18T02:22:43.240 に答える