Search code examples
javaandroidhuawei-mobile-serviceshuawei-developersharmonyos

How to get the touch coordinates of a touch event in HarmonyOS?


I am writing a helper class to zoom an image in HarmonyOS using Java SDK. I want to get the touch coordinates of the dispatched touch, in Android we can use the following code snippet.

MotionEvent.PointerCoords pointerCoords = new MotionEvent.PointerCoords(); 
event.getPointerCoords(index, pointerCoords); 

What is the alternative for the above in HarmonyOS?


Solution

  • According to the team, HarmonyOS does not currently have the alternative method for this. But there are plans to support it in the future.

    If you just want to get touch screen coordinates, you may can refer to this Docs.

    You can take a look at the TouchEvnt.getPointerPosition(touchEvent.getIndex()) section to see if it can help you.