private int[] getPositionInTouch(TouchEvent<? extends EventHandler> event) {
    if (event instanceof TouchEndEvent) return new int[] {previousX, previousY};

    JsArray<Touch> touches = event.getTouches();
    if (touches == null || touches.length() == 0) return null;
    // Get the first touch
    Touch touch = touches.get(0);
    int x = touch.getRelativeX(canvas.getElement());
    int y = touch.getRelativeY(canvas.getElement());
    return new int[] {x, y};
  }
Ejemplo n.º 2
0
 public static boolean isTouchSupported() {
   return TouchEvent.isSupported();
 }