How do I get the coordinates that the user touches? I am using xui and Javascript.
On my index.html I do not know how to get the x and y coordinates from a user interaction.
How do I get the coordinates that the user touches? I am using xui and Javascript.
On my index.html I do not know how to get the x and y coordinates from a user interaction.
Copyright © 2021 Jogjafile Inc.
if you use xui for event binding then the event callback function gets
TocuhEventobject (e) as its parameterNow TouchEvent isn't like MouseEvent where you can have only one input at a time - as TouchEvent object handles multitouch multiple touches at the same time.
To get the touch that was captured on your element you have to get it from
e.touches- which is all touches currently active on the device,e.targetTouches- all the touches which are on the current target.a_buttonin our example ore.changedTouches- touches which triggered the event. For touchstart (best responsiveness) you can grab first element ofe.changedTouchesas it will be the touch that triggered yourtouchstartevent to get theTouchobject representing your touch.Now
Touchobject holds all the data you need to get any info on what's happening on the screen.