getTouchPoints method
Gets the x,y
positions in pixels from a touch event e
.
If several fingers touched, the returned list is > 1.
The returned x,y
list is relative to the page.
Return null if e
is not touch event or the number of touches is 0.
Implementation
static List<Point<int>> getTouchPoints(UIEvent e) {
int x, y;
List<Point<int>> tpoints;
if (e is MouseEvent) {
x = e.page.x;
y = e.page.y;
tpoints = [Point(x, y)];
} else if (!(e is TouchEvent)) {
tpoints = [Point(0, 0)];
} else {
TouchEvent et = e;
if (et.touches == null || et.touches.isEmpty) return null;
tpoints = List<Point<int>>(et.touches.length);
for (int i = 0; i < tpoints.length; i++) {
x = et.touches[i].page.x;
y = et.touches[i].page.y;
tpoints[i] = Point(x, y);
}
}
return tpoints;
}