diff --git a/lime/ui/TouchEventManager.hx b/lime/ui/TouchEventManager.hx index 067dbb3bc..70638b99b 100644 --- a/lime/ui/TouchEventManager.hx +++ b/lime/ui/TouchEventManager.hx @@ -63,14 +63,34 @@ import flash.Lib; if (window != null && window.element != null) { - var rect = window.element.getBoundingClientRect (); - eventInfo.x = (touch.pageX - rect.left) * (window.width / rect.width); - eventInfo.y = (touch.pageY - rect.top) * (window.height / rect.height); + if (window.canvas != null) { + + var rect = window.canvas.getBoundingClientRect (); + eventInfo.x = (touch.clientX - rect.left) * (window.width / rect.width); + eventInfo.y = (touch.clientY - rect.top) * (window.height / rect.height); + + } else if (window.div != null) { + + var rect = window.div.getBoundingClientRect (); + //eventInfo.x = (event.clientX - rect.left) * (window.div.style.width / rect.width); + eventInfo.x = (touch.clientX - rect.left); + //eventInfo.y = (event.clientY - rect.top) * (window.div.style.height / rect.height); + eventInfo.y = (touch.clientY - rect.top); + + } else { + + var rect = window.element.getBoundingClientRect (); + eventInfo.x = (touch.clientX - rect.left) * (window.width / rect.width); + eventInfo.y = (touch.clientY - rect.top) * (window.height / rect.height); + + } + + } else { - eventInfo.x = touch.pageX; - eventInfo.y = touch.pageY; + eventInfo.x = touch.clientX; + eventInfo.y = touch.clientY; }