private void registerHandlers() { if(BrowserUtils.isMobile) { registerHandler(this.addDomHandler(this, TouchStartEvent.getType())); registerHandler(this.addDomHandler(this, TouchEndEvent.getType())); } else { registerHandler(this.addDomHandler(this, MouseDownEvent.getType())); registerHandler(this.addDomHandler(this, MouseUpEvent.getType())); registerHandler(this.addDomHandler(this, MouseOutEvent.getType())); } registerHandler(this.addHandler(this, DragStartEvent.getType())); registerHandler(this.addHandler(this, DragMoveEvent.getType())); registerHandler(this.addHandler(this, DragEndEvent.getType())); registerHandler(this.addHandler(this, DragCancelEvent.getType())); }
private TabBarItemComponent createSystemTabItem(EnumSystemTabItemType itemType) { TabBarItem tabBarItem = null; TabBarItemComponent component = null; AutoBean<TabBarItem> TabBarItemBean = AutoBeanService.getInstance().getFactory().tabBarItem(); tabBarItem = TabBarItemBean.as(); switch (itemType) { case PREVIOUS: tabBarItem.setName("<"); break; case NEXT: tabBarItem.setName(">"); break; } component = new TabBarItemComponent(tabBarItem, itemType); // Add handlers as not created by usual mechanism if(BrowserUtils.isMobile) { systemTabHandlers.add(component.addDomHandler(this, TouchStartEvent.getType())); systemTabHandlers.add(component.addDomHandler(this, TouchEndEvent.getType())); } else { systemTabHandlers.add(component.addDomHandler(this, MouseDownEvent.getType())); systemTabHandlers.add(component.addDomHandler(this, MouseUpEvent.getType())); systemTabHandlers.add(component.addDomHandler(this, MouseOutEvent.getType())); } systemTabHandlers.add(component.addHandler(component, TapEvent.getType())); return component; }
@Override public void onTouchEnd(TouchEndEvent p_event) { if (!m_hasTouchMoved) { p_event.preventDefault(); Touch touch = p_event.getChangedTouches().get(0); Element current = getElement(); Element parent = current.getParentElement(); int x = touch.getPageX() - current.getOffsetLeft() - parent.getOffsetLeft(); int y = touch.getPageY() - current.getOffsetTop() - parent.getOffsetTop(); onUp(UserAction.Touch, x, y); } }
@Override public List<HandlerRegistration> applyController(VectorObject shape, MapController mapController) { List<HandlerRegistration> registrations = new ArrayList<HandlerRegistration>(); registrations.add(shape.addMouseDownHandler(mapController)); registrations.add(shape.addMouseUpHandler(mapController)); registrations.add(shape.addMouseMoveHandler(mapController)); registrations.add(shape.addMouseOutHandler(mapController)); registrations.add(shape.addMouseOverHandler(mapController)); registrations.add(shape.addMouseWheelHandler(mapController)); registrations.add(shape.addDoubleClickHandler(mapController)); registrations.add(shape.addDomHandler(mapController, TouchStartEvent.getType())); registrations.add(shape.addDomHandler(mapController, TouchEndEvent.getType())); registrations.add(shape.addDomHandler(mapController, TouchMoveEvent.getType())); registrations.add(shape.addDomHandler(mapController, TouchCancelEvent.getType())); return registrations; }
@Test public void shouldAddTouchEndHandlerOnImage() { // given TouchOnImageEndHandler touchOnImageEndHandler = mock(TouchOnImageEndHandler.class); TouchEndHandlerOnImage touchEndHandlerOnImage = mock(TouchEndHandlerOnImage.class); when(touchHandlerFactory.createTouchEndHandlerOnImage(touchOnImageEndHandler)).thenReturn(touchEndHandlerOnImage); // when testObj.addTouchOnImageEndHandler(touchOnImageEndHandler, listenOn); // then verify(listenOn).addDomHandler(touchEndHandlerOnImage, TouchEndEvent.getType()); }
@Test public void shouldAddTouchEndHandler_ifNotIE() { // given TouchOnEndHandler touchOnStartHandler = mock(TouchOnEndHandler.class); // when testObj.addTouchEndHandler(touchOnStartHandler, listenOn); // then verify(listenOn).addDomHandler(any(TouchEndHandlerImpl.class), eq(TouchEndEvent.getType())); }
private void registerHandlers() { if(BrowserUtils.isMobile) { registerHandler(this.addDomHandler(this, TouchStartEvent.getType())); registerHandler(this.addDomHandler(this, TouchEndEvent.getType())); registerHandler(this.addDomHandler(this, TouchMoveEvent.getType())); } else { registerHandler(this.addDomHandler(this, MouseDownEvent.getType())); registerHandler(this.addDomHandler(this, MouseUpEvent.getType())); registerHandler(this.addDomHandler(this, MouseOutEvent.getType())); registerHandler(this.addDomHandler(this, MouseMoveEvent.getType())); } }
@Override public void onTouchEnd(TouchEndEvent event) { if (startEvent != null) { event.stopPropagation(); PressEndEvent endEvent = new PressEndEvent(startEvent); if (endEvent != null) { eventBus.fireEvent(startEvent); eventBus.fireEvent(endEvent); } reset(); } }
@Override public void onTouchEnd(TouchEndEvent event) { event.stopPropagation(); PressEndEvent endEvent = null; if (lastMoveEvent != null) { endEvent = new PressEndEvent(lastMoveEvent); } else if (startEvent != null) { endEvent = new PressEndEvent(startEvent); } if (endEvent != null) { eventBus.fireEvent(endEvent); this.fireEvent(endEvent); } reset(); }
public void onTouchEnd(TouchEndEvent event) { // GWT.log("touchend");; event.preventDefault(); if (enabled && dragging) { dragging=false; draw(); if (command!=null) command.execute(); } }
private static Point getPoint(EventHandlingTarget drawPanelCanvas, HumanInputEvent<?> event) { Element e = drawPanelCanvas.getElement(); if (event instanceof MouseEvent<?>) { return new Point(((MouseEvent<?>) event).getRelativeX(e), ((MouseEvent<?>) event).getRelativeY(e)); } else if (event instanceof TouchEndEvent) { return new Point(((TouchEvent<?>) event).getChangedTouches().get(0).getRelativeX(e), ((TouchEvent<?>) event).getChangedTouches().get(0).getRelativeY(e)); } else if (event instanceof TouchEvent<?>) { return new Point(((TouchEvent<?>) event).getTouches().get(0).getRelativeX(e), ((TouchEvent<?>) event).getTouches().get(0).getRelativeY(e)); } else { throw new RuntimeException("Unknown Event Type: " + event); } }
private static Point getPointAbsolute(HumanInputEvent<?> event) { if (event instanceof MouseEvent<?>) { return new Point(((MouseEvent<?>) event).getClientX(), ((MouseEvent<?>) event).getClientY()); } else if (event instanceof TouchEndEvent) { return new Point(((TouchEvent<?>) event).getChangedTouches().get(0).getPageX(), ((TouchEvent<?>) event).getChangedTouches().get(0).getPageY()); } else if (event instanceof TouchEvent<?>) { return new Point(((TouchEvent<?>) event).getTouches().get(0).getPageX(), ((TouchEvent<?>) event).getTouches().get(0).getPageY()); } else { throw new RuntimeException("Unknown Event Type: " + event); } }
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()); }
@Override public void onTouchEnd(TouchEndEvent event) { if (touchId == null) return; JsArray<Touch> touches = event.getTouches(); for (int i = 0; i < touches.length(); i++) { Touch touch = touches.get(i); if (touch.getIdentifier() == touchId) return; } touchId = null; event.preventDefault(); }
@Override public void onTouchEnd(TouchEndEvent p_event) { Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId); if (touch != null) { m_currentTouchEventId = -1; onUp(Element.as(touch.getTarget())); } }
@Override public void onTouchEnd(TouchEndEvent event) { // button.setText("onTouchEnd:" + event.getTouches().length() + ":" + event.getTargetTouches().length()); event.preventDefault(); // if (hasTargetTouch && event.getTargetTouches().length() == 0) { eventFired(); // } }
@Override public void onTouchEnd(TouchEndEvent event) { containerScrollStartPosY = -1; containerScrollStartPosX = -1; GanttWidget.this.onTouchOrMouseUp(event.getNativeEvent()); event.preventDefault(); }
public void onMapInitialized(MapInitializationEvent event) { VectorContainer container = mapPresenter.getContainerManager().addScreenContainer(); rectangle = new Rectangle(60, 40, 200, 80); rectangle.setFillColor("#CC9900"); rectangle.setFillOpacity(0.4); text = new Text(70, 60, "Drag me..."); text.setFontFamily("Arial"); text.setFontSize(16); text.setStrokeOpacity(0); text.setFillColor("#000000"); container.add(text); container.add(rectangle); DragHandler dragHandler = new DragHandler(); rectangle.addMouseDownHandler(dragHandler); rectangle.addMouseUpHandler(dragHandler); rectangle.addMouseMoveHandler(dragHandler); rectangle.addMouseOutHandler(dragHandler); rectangle.addDomHandler(dragHandler, TouchMoveEvent.getType()); rectangle.addDomHandler(dragHandler, TouchStartEvent.getType()); rectangle.addDomHandler(dragHandler, TouchEndEvent.getType()); text.addMouseDownHandler(dragHandler); text.addMouseUpHandler(dragHandler); text.addMouseMoveHandler(dragHandler); text.addMouseOutHandler(dragHandler); }
private void addMouseDownHandlers() { m_container.addDomHandler(this, MouseWheelEvent.getType()); m_container.addDomHandler(this, MouseOverEvent.getType()); m_container.addDomHandler(this, MouseOutEvent.getType()); m_container.addDomHandler(this, MouseMoveEvent.getType()); m_container.addDomHandler(this, MouseUpEvent.getType()); m_container.addDomHandler(this, MouseDownEvent.getType()); m_container.addDomHandler(this, TouchStartEvent.getType()); m_container.addDomHandler(this, TouchEndEvent.getType()); m_container.addDomHandler(this, TouchMoveEvent.getType()); }
@Override public void onTouchEnd(TouchEndEvent event) { m_isTouching = event.getTouches().length() != 0; if( !m_isMouseDown ) return; onMouseOrTouchUp(event, (int)m_mousePoint.getX(), (int)m_mousePoint.getY(), true); }
private void addHandlers() { addDomHandler(this, KeyUpEvent.getType()); if (TouchEvent.isSupported()) { addDomHandler(this, TouchStartEvent.getType()); addDomHandler(this, TouchMoveEvent.getType()); addDomHandler(this, TouchEndEvent.getType()); addDomHandler(this, TouchCancelEvent.getType()); } else { addDomHandler(this, MouseDownEvent.getType()); addDomHandler(this, MouseUpEvent.getType()); addDomHandler(this, MouseMoveEvent.getType()); } addDomHandler(this, FocusEvent.getType()); addDomHandler(this, BlurEvent.getType()); }
@Override public void onTouchEnd(TouchEndEvent event) { if (touchStarted) { event.preventDefault(); event.stopPropagation(); NativeEvent nativeEvent = event.getNativeEvent(); NativeEvent evt = Document.get().createClickEvent(1, nativeEvent.getScreenX(), nativeEvent.getScreenY(), nativeEvent.getClientX(), nativeEvent.getClientY(), false, false, false, false); getElement().dispatchEvent(evt); touchStarted = false; fastClickAt = new Date(); } }
public void onTouchEnd(TouchEndEvent event) { if (touchStarted) { event.preventDefault(); event.stopPropagation(); NativeEvent nativeEvent = event.getNativeEvent(); NativeEvent evt = Document.get().createClickEvent(1, nativeEvent.getScreenX(), nativeEvent.getScreenY(), nativeEvent.getClientX(), nativeEvent.getClientY(), false, false, false, false); getElement().dispatchEvent(evt); touchStarted = false; fastClickAt = new Date(); } }
@Override public void onTouchEnd(TouchEndEvent event) { event.preventDefault(); touchOnEndHandler.onEnd(touchToImageEvent.getTouchOnImageEvent(event)); }
@Override public void addTouchOnImageEndHandler(final TouchOnImageEndHandler touchEndHandler, Widget listenOn) { TouchEndHandlerOnImage touchEndHandlerOnImage = touchHandlerFactory.createTouchEndHandlerOnImage(touchEndHandler); listenOn.addDomHandler(touchEndHandlerOnImage, TouchEndEvent.getType()); }
@Override public void addTouchEndHandler(final TouchOnEndHandler touchEndHandler, Widget listenOn) { listenOn.addDomHandler(new TouchEndHandlerImpl(touchEndHandler), TouchEndEvent.getType()); }
@Override public void onTouchEnd(TouchEndEvent event) { touchOnEndHandler.onEnd(event.getNativeEvent()); }
public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { return addDomHandler(handler, TouchEndEvent.getType()); }
@Override void registerGwtHandler() { addDomHandler(this, TouchEndEvent.getType()); }
@Override boolean dispatch(TouchEndEvent event, Element context, WaveTouchEndHandler handler) { return handler.onTouchEnd(event, context); }
@Override public void onTouchEnd(TouchEndEvent event) { if (dispatch(event, event.getNativeEvent().getEventTarget().<Element>cast())) { event.stopPropagation(); } }
@Override public com.google.gwt.event.shared.HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { return this.addDomHandler(handler, TouchEndEvent.getType()); }
@Override public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { return this.addDomHandler(handler, TouchEndEvent.getType()); }
/** * 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; } } }
public MapController(Map map, final Controller controller) { this.map = map; mouseMoveHandler = new MouseMoveHandler() { public void onMouseMove(MouseMoveEvent event) { controller.onMouseMove(event); } }; mouseOutHandler = new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { controller.onMouseOut(event); } }; mouseOverHandler = new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { controller.onMouseOver(event); } }; downHandler = new DownHandler() { public void onDown(HumanInputEvent<?> event) { if (event instanceof MouseDownEvent) { controller.onMouseDown((MouseDownEvent) event); } else if (event instanceof TouchStartEvent) { controller.onTouchStart((TouchStartEvent) event); } } }; upHandler = new UpHandler() { public void onUp(HumanInputEvent<?> event) { if (event instanceof MouseUpEvent) { controller.onMouseUp((MouseUpEvent) event); } else if (event instanceof TouchEndEvent) { controller.onTouchEnd((TouchEndEvent) event); } } }; dragHandler = new DragHandler() { public void onDrag(HumanInputEvent<?> event) { if (controller instanceof AbstractController) { ((AbstractController) controller).onDrag(event); } } }; doubleClickHandler = new DoubleClickHandler() { public void onDoubleClick(DoubleClickEvent event) { controller.onDoubleClick(event); } }; }
public EventListenerHelper(Element e, GraphicsController gc, int eventMask) { this.e = e; this.hm = new HandlerManager(e); if ((Event.ONMOUSEDOWN & eventMask) > 0) { hm.addHandler(MouseDownEvent.getType(), gc); } if ((Event.ONMOUSEUP & eventMask) > 0) { hm.addHandler(MouseUpEvent.getType(), gc); } if ((Event.ONMOUSEOUT & eventMask) > 0) { hm.addHandler(MouseOutEvent.getType(), gc); } if ((Event.ONMOUSEOVER & eventMask) > 0) { hm.addHandler(MouseOverEvent.getType(), gc); } if ((Event.ONMOUSEMOVE & eventMask) > 0) { hm.addHandler(MouseMoveEvent.getType(), gc); } if ((Event.ONMOUSEWHEEL & eventMask) > 0) { hm.addHandler(MouseWheelEvent.getType(), gc); } if ((Event.ONDBLCLICK & eventMask) > 0) { hm.addHandler(DoubleClickEvent.getType(), gc); } if ((Event.ONTOUCHSTART & eventMask) > 0) { hm.addHandler(TouchStartEvent.getType(), gc); } if ((Event.ONTOUCHEND & eventMask) > 0) { hm.addHandler(TouchEndEvent.getType(), gc); } if ((Event.ONTOUCHMOVE & eventMask) > 0) { hm.addHandler(TouchMoveEvent.getType(), gc); } if ((Event.ONTOUCHCANCEL & eventMask) > 0) { hm.addHandler(TouchCancelEvent.getType(), gc); } }
@Override public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { return addDomHandler(handler, TouchEndEvent.getType()); }
@Override public void onTouchEnd(TouchEndEvent event) { dragging = false; }