문제

테이프 핸들러로 전달되는 테이프 객체에서 탭 좌표를 얻는 방법을 찾는 데 어려움이 있습니다 (어쨌든 사양을 찾지 못했습니다). 또한 사용자 지정 변수 "x"를 "y"로 전달하는 싱글 랩 이벤트도 있습니다. 이는 좌표라고 생각합니다.

요점은 내가 큰 요소를 가지고있는 하나의 응용 프로그램에서 작업 중이며 정확히 사용자가 어디에서 탭했는지 알아야한다는 것입니다 (아마도 내 요소의 글로벌 화면 좌표 또는 상대 좌표).

예제 코드는 다음과 같습니다.

//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?
}

제안해 주셔서 대단히 감사합니다.

도움이 되었습니까?

해결책

탭 이벤트의 X 및 Y 좌표는 이벤트의 "다운"속성에 있습니다.

전.

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top