Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.Touch


                }
                /*
                 * TODO calculate based on real distance instead of separate
                 * axis checks
                 */
                Touch touch = event.getChangedTouches().get(0);
                if (Math.abs(touch.getClientX() - touchStartX) > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
                    return true;
                }
                if (Math.abs(touch.getClientY() - touchStartY) > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
                    return true;
                }
                return false;
            }
View Full Code Here


        return isTouchEvent(Event.as(event));
    }

    public static void simulateClickFromTouchEvent(Event touchevent,
            Widget widget) {
        Touch touch = touchevent.getChangedTouches().get(0);
        final NativeEvent createMouseUpEvent = Document.get()
                .createMouseUpEvent(0, touch.getScreenX(), touch.getScreenY(),
                        touch.getClientX(), touch.getClientY(), false, false,
                        false, false, NativeEvent.BUTTON_LEFT);
        final NativeEvent createMouseDownEvent = Document.get()
                .createMouseDownEvent(0, touch.getScreenX(),
                        touch.getScreenY(), touch.getClientX(),
                        touch.getClientY(), false, false, false, false,
                        NativeEvent.BUTTON_LEFT);
        final NativeEvent createMouseClickEvent = Document.get()
                .createClickEvent(0, touch.getScreenX(), touch.getScreenY(),
                        touch.getClientX(), touch.getClientY(), false, false,
                        false, false);

        /*
         * Get target with element from point as we want the actual element, not
         * the one that sunk the event.
         */
        final Element target = getElementFromPoint(touch.getClientX(),
                touch.getClientY());
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            public void execute() {
                try {
                    target.dispatchEvent(createMouseDownEvent);
                    target.dispatchEvent(createMouseUpEvent);
View Full Code Here

        {
            int size = jsarray.length();

            for (int i = 0; i < size; i++)
            {
                Touch touch = jsarray.get(i);

                touches.add(new TouchPoint(touch.getRelativeX(element), touch.getRelativeY(element)));
            }
        }
        else
        {
            int x = event.getNativeEvent().getClientX() - element.getAbsoluteLeft() + element.getScrollLeft() + element.getOwnerDocument().getScrollLeft();
View Full Code Here

    if (!touching) {
      return;
    }

    // Check if we should start dragging.
    Touch touch = getTouchFromEvent(event);
    Point touchPoint = new Point(touch.getPageX(), touch.getPageY());
    double touchTime = Duration.currentTimeMillis();
    lastTouchPosition.setTemporalPoint(touchPoint, touchTime);
    if (!dragging) {
      Point diff = touchPoint.minus(startTouchPosition);
      double absDiffX = Math.abs(diff.getX());
View Full Code Here

    cancelAll();
    touching = true;

    // Record the starting touch position.
    Touch touch = getTouchFromEvent(event);
    startTouchPosition = new Point(touch.getPageX(), touch.getPageY());
    double startTouchTime = Duration.currentTimeMillis();
    recentTouchPosition.setTemporalPoint(startTouchPosition, startTouchTime);
    lastTouchPosition.setTemporalPoint(startTouchPosition, startTouchTime);
    recentTouchPositionOnDeck = null;
View Full Code Here

  @Override
  public void onTouchMove(TouchMoveEvent event) {
    switch (state) {
      case TWO_FINGER:

        Touch touch1 = event.getTouches().get(0);
        Touch touch2 = event.getTouches().get(1);

        int left = offsetProvider.getLeft();
        int top = offsetProvider.getTop();

        int x1 = touch1.getPageX() - left;
        int y1 = touch1.getPageY() - top;
        int x2 = touch2.getPageX() - left;
        int y2 = touch2.getPageY() - top;

        double newDistance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
        int x = (x1 + x2) / 2;
        int y = (y1 + y2) / 2;
View Full Code Here

    @SuppressWarnings("unchecked")
    JsArray<Touch> touchArray = mock(JsArray.class);
    when(event.getTouches()).thenReturn(touchArray);
    int count = 0;
    for(; count < positions.length; count +=2) {
      Touch touch = mock(Touch.class);
      when(touchArray.get(count / 2)).thenReturn(touch);
      when(touch.getPageX()).thenReturn(positions[count]);
      when(touch.getPageY()).thenReturn(positions[count + 1]);
    }
    when(touchArray.length()).thenReturn(count / 2);
  }
View Full Code Here

    }

    @Override
    public void onTouchMove(TouchMoveEvent event) {
      Touch touch = event.getTouches().get(0);
      if (Math.abs(touch.getPageX() - x) > Tap.RADIUS
          || Math.abs(touch.getPageY() - y) > Tap.RADIUS) {
        moved = true;
        // deselect
        if (node != null) {
          node.removeClassName(CellList.this.appearance.css().selected());
          stopTimer();
View Full Code Here

        if (!isEnabled())
          return;

        if (ignore)
          return;
        Touch touch = event.getTouches().get(0);
        last_x = touch.getPageX();
        last_y = touch.getPageY();

      }

      @Override
      public void onTouchStart(TouchStartEvent event) {
        if (!isEnabled())
          return;
        ignore = inputRadio.isChecked();

        if (ignore)
          return;

        Touch touch = event.getTouches().get(0);
        start_x = touch.getPageX();
        start_y = touch.getPageY();
        last_x = start_x;
        last_y = start_y;

        EventTarget eventTarget = event.getNativeEvent().getEventTarget();
        labelOrContainer = true;
View Full Code Here

      if (isReadOnly()) {
        return;
      }
      event.stopPropagation();
      event.preventDefault();
      Touch touch = event.getTouches().get(0);
      now_x = touch.getClientX();
      if (!moved) {
        if (Math.abs(now_x - x_start) < appearance.css().DRAG_DEADZONE()) {
          return;
        }
      }
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.Touch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.