com.google.gwt.event.dom.client.TouchStartEvent Java Examples

The following examples show how to use com.google.gwt.event.dom.client.TouchStartEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SvgArrowWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void setUpEventHandlers(boolean touchSupported,
        boolean msTouchSupported) {
    this.touchSupported = touchSupported;
    this.msTouchSupported = msTouchSupported;
    if (msTouchSupported) {
        addDomHandler(pointerDownHandler, PointerDownEvent.getType());
        addDomHandler(pointerUpHandler, PointerUpEvent.getType());
    } else if (touchSupported) {
        addDomHandler(touchStartHandler, TouchStartEvent.getType());
    } else {
        addHandler(mouseDownHandler, MouseDownEvent.getType());
    }
    registerMouseDownAndTouchDownEventListener(startingPoint);
    registerMouseDownAndTouchDownEventListener(endingPoint);
}
 
Example #2
Source File: AbstractPaletteItemWidget.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
AbstractPaletteItemWidget(SimpleComponentDescriptor scd, ImageResource image) {
  this.scd = scd;

  AbstractImagePrototype.create(image).applyTo(this);
  this.addStyleName("ode-SimplePaletteItem-button");

  addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      handleClick();
    }
  });
  addTouchStartHandler(new TouchStartHandler() {
    @Override
    public void onTouchStart(TouchStartEvent touchStartEvent) {
      // Otherwise captured by SimplePaletteItem
      touchStartEvent.stopPropagation();
    }
  });
  addTouchEndHandler(new TouchEndHandler() {
    @Override
    public void onTouchEnd(TouchEndEvent touchEndEvent) {
      handleClick();
    }
  });
}
 
Example #3
Source File: VLayoutDragDropMouseHandler.java    From cuba with Apache License 2.0 6 votes vote down vote up
/**
 * Start listening to events
 */
private void attach() {
    if (handlers.isEmpty()) {
        if (attachTarget == null) {
            handlers.add(
                    root.addDomHandler(this, MouseDownEvent.getType()));
            handlers.add(
                    root.addDomHandler(this, TouchStartEvent.getType()));
        } else {
            handlers.add(attachTarget.addDomHandler(this,
                    MouseDownEvent.getType()));
            handlers.add(attachTarget.addDomHandler(this,
                    TouchStartEvent.getType()));
        }
    }
}
 
Example #4
Source File: SimplePaletteItem.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private void addHandlers() {
  addMouseDownHandler(new MouseDownHandler() {
    @Override
    public void onMouseDown(MouseDownEvent arg0) {
      select(getWidget());
    }
  });
  addTouchStartHandler(new TouchStartHandler() {
    @Override
    public void onTouchStart(TouchStartEvent event) {
      select(getWidget());
    }
  });
}
 
Example #5
Source File: VLayoutDragDropMouseHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onTouchStart(TouchStartEvent event) {
    NativeEvent nativeEvent = event.getNativeEvent();
    if (isElementNode(nativeEvent) && isChildOfRoot(nativeEvent)) {
        if (startDragOnMove) {
            initiateDragOnMove(event.getNativeEvent());
        } else {
            initiateDrag(event.getNativeEvent());
        }
    }
}
 
Example #6
Source File: SinglePageLayout.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onTouchStart(TouchStartEvent event) {
	if (isOnText(event)) {
		enableScrollPageJump = false;
	} else {
		widget.getElement().focus();
		super.onTouchStart(event);
	}
}
 
Example #7
Source File: UIHider.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
public UIHider(int uiHideDelay, Widget textLayer) {
	this.uiHideDelay = uiHideDelay;
	textLayer.addDomHandler(this, MouseMoveEvent.getType());
	textLayer.addDomHandler(this, KeyDownEvent.getType());
	textLayer.addDomHandler(this, ScrollEvent.getType());
	textLayer.addDomHandler(this, TouchStartEvent.getType());
}
 
Example #8
Source File: DragSourceSupport.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Call the equivalent mouse event handler for each touch event
 */
@Override
public void onTouchStart(TouchStartEvent event) {
  event.preventDefault();
  Widget src = (Widget) event.getSource();
  Touch touch = event.getTargetTouches().get(0);
  com.google.gwt.dom.client.Element target = com.google.gwt.dom.client.Element.as(touch.getTarget());
  int x = touch.getRelativeX(target);
  int y = touch.getRelativeY(target);
  onMouseDown(src, x, y);
}
 
Example #9
Source File: PanListener.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
public PanListener(Widget widget) {
	this.widget = widget;
	widget.addDomHandler(this, MouseDownEvent.getType());
	widget.addDomHandler(this, MouseUpEvent.getType());
	widget.addDomHandler(this, MouseMoveEvent.getType());
	widget.addDomHandler(this, TouchStartEvent.getType());
	widget.addDomHandler(this, TouchEndEvent.getType());
	widget.addDomHandler(this, TouchMoveEvent.getType());
}
 
Example #10
Source File: PanListener.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onTouchStart(TouchStartEvent event) {
	if (touchId != null || isMouseDown)
		return;
	Touch touch = event.getTouches().get(0);
	touchId = touch.getIdentifier();
	x = touch.getClientX();
	y = touch.getClientY();
	event.preventDefault();
}
 
Example #11
Source File: GanttWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onTouchStart(TouchStartEvent event) {
    if (event.getTargetTouches().length() == 1) {
        JavaScriptObject target = event.getNativeEvent().getEventTarget().cast();
        containerScrollStartPosY = -1;
        containerScrollStartPosX = -1;

        if (target == container || target == content || (!isMovableSteps())) {
            boolean preventDefaultAndReturn = false;
            // store x,y position for 'manual' vertical scrolling
            if (isContentOverflowingVertically()) {
                containerScrollStartPosY = container.getScrollTop() + event.getTouches().get(0).getPageY();
                preventDefaultAndReturn = true;
            }
            if (isContentOverflowingHorizontally()) {
                containerScrollStartPosX = container.getScrollLeft() + event.getTouches().get(0).getPageX();
                preventDefaultAndReturn = true;
            }
            if (preventDefaultAndReturn) {
                event.preventDefault();
                return;
            }
        }
        GanttWidget.this.onTouchOrMouseDown(event.getNativeEvent());
    }
    event.preventDefault();
}
 
Example #12
Source File: UIHider.java    From djvu-html5 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onTouchStart(TouchStartEvent event) {
	isMouseOverUI = false;
	showUI();
}
 
Example #13
Source File: SvgArrowWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public void onTouchStart(TouchStartEvent event) {
    GWT.log("Starting point touched (touchDown)!");

    handleDownEvent(event.getNativeEvent());
}
 
Example #14
Source File: GanttWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
/**
 * Reset listeners.
 */
public void resetListeners() {
    Event.sinkEvents(container, Event.ONSCROLL | Event.ONCONTEXTMENU);

    if (contextMenuHandlerRegistration == null) {
        contextMenuHandlerRegistration = addDomHandler(contextMenuHandler, ContextMenuEvent.getType());
    }

    if (scrollHandlerRegistration == null) {
        scrollHandlerRegistration = addHandler(scrollHandler, ScrollEvent.getType());
    }
    if (isMsTouchSupported()) {
        // IE10 pointer events (ms-prefixed events)
        if (pointerDownHandlerRegistration == null) {
            pointerDownHandlerRegistration = addDomHandler(msPointerDownHandler, PointerDownEvent.getType());
        }
        if (pointerUpHandlerRegistration == null) {
            pointerUpHandlerRegistration = addDomHandler(msPointerUpHandler, PointerUpEvent.getType());
        }
        if (pointerMoveHandlerRegistration == null) {
            pointerMoveHandlerRegistration = addDomHandler(msPointerMoveHandler, PointerMoveEvent.getType());
        }
        if (pointerCancelHandlerRegistration == null) {
            pointerCancelHandlerRegistration = addHandler(msPointerCancelHandler, PointerCancelEvent.getType());
        }
    } else if (touchSupported) {
        // touch events replaces mouse events
        if (touchStartHandlerRegistration == null) {
            touchStartHandlerRegistration = addDomHandler(touchStartHandler, TouchStartEvent.getType());
        }
        if (touchEndHandlerRegistration == null) {
            touchEndHandlerRegistration = addDomHandler(touchEndHandler, TouchEndEvent.getType());
        }
        if (touchMoveHandlerRegistration == null) {
            touchMoveHandlerRegistration = addDomHandler(touchMoveHandler, TouchMoveEvent.getType());
        }
        if (touchCancelHandlerRegistration == null) {
            touchCancelHandlerRegistration = addHandler(touchCancelHandler, TouchCancelEvent.getType());
        }

    } else {
        if (mouseDblClickHandlerRegistration == null) {
            mouseDblClickHandlerRegistration = addDomHandler(doubleClickHandler, DoubleClickEvent.getType());
        }
        if (mouseDownHandlerRegistration == null) {
            mouseDownHandlerRegistration = addDomHandler(mouseDownHandler, MouseDownEvent.getType());
        }
        if (mouseUpHandlerRegistration == null) {
            mouseUpHandlerRegistration = addDomHandler(mouseUpHandler, MouseUpEvent.getType());
        }
        if (isMovableSteps() || isResizableSteps()) {
            if (mouseMoveHandlerRegistration == null) {
                mouseMoveHandlerRegistration = addDomHandler(mouseMoveHandler, MouseMoveEvent.getType());
            }
        } else if (mouseMoveHandlerRegistration != null) {
            mouseMoveHandlerRegistration.removeHandler();
            mouseMoveHandlerRegistration = null;
        }
    }
}
 
Example #15
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public HandlerRegistration addTouchStartHandler(TouchStartHandler handler) {
	return this.addDomHandler(handler, TouchStartEvent.getType());
}
 
Example #16
Source File: ListItem.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public HandlerRegistration addTouchStartHandler(TouchStartHandler handler) {
	return this.addDomHandler(handler, TouchStartEvent.getType());
}
 
Example #17
Source File: AbstractInput.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public com.google.gwt.event.shared.HandlerRegistration addTouchStartHandler(TouchStartHandler handler) {
	return this.addDomHandler(handler, TouchStartEvent.getType());
}
 
Example #18
Source File: MockComponent.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public final HandlerRegistration addTouchStartHandler(TouchStartHandler handler) {
  return handlers.addHandler(TouchStartEvent.getType(), handler);
}
 
Example #19
Source File: HandlerPanel.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
public HandlerRegistration addTouchStartHandler(TouchStartHandler handler) {
  return addDomHandler(handler, TouchStartEvent.getType());
}