List of usage examples for com.google.gwt.dom.client Touch getClientX
public final int getClientX()
From source file:ch.unifr.pai.twice.dragndrop.client.TouchDragNDrop.java
License:Apache License
/** * return the x position of the touch instead of the mouse * /* ww w . j a v a2 s. co m*/ * @see ch.unifr.pai.twice.dragndrop.client.MPDragNDrop#getX(com.google.gwt.dom.client.NativeEvent) */ @Override int getX(NativeEvent event) { if (event.getTouches().length() > 0) { Touch t = event.getTouches().get(0); return t.getClientX(); } // if(event.getTouches().length()>0){ // Touch t = event.getTouches().shift(); // return t.getClientX(); // } return 0; }
From source file:ch.unifr.pai.twice.mousecontrol.client.TouchPadMobileWidget.java
License:Apache License
/** * On movement, calculate the new position of the mouse pointer on the shared screen * //from ww w. j a v a 2s.c o m * @see com.google.gwt.event.dom.client.TouchMoveHandler#onTouchMove(com.google.gwt.event.dom.client.TouchMoveEvent) */ @Override public void onTouchMove(TouchMoveEvent event) { event.preventDefault(); event.stopPropagation(); if (event.getTouches().length() > 0) { Touch t = event.getTouches().get(0); int x = t.getClientX(); int y = t.getClientY(); int dX = x - lastX; int dY = y - lastY; if (Math.abs(dX) > MOVEMENTTHRESHOLD || Math.abs(dY) > MOVEMENTTHRESHOLD) { mouseDownTimer.cancel(); lastX = x; lastY = y; updatePos(dX, dY); move = true; } } }
From source file:ch.unifr.pai.twice.mousecontrol.client.TouchPadMobileWidget.java
License:Apache License
/** * On touch start, check if it is the begin of a drag. * /*from ww w .j a v a2 s.co m*/ * @see com.google.gwt.event.dom.client.TouchStartHandler#onTouchStart(com.google.gwt.event.dom.client.TouchStartEvent) */ @Override public void onTouchStart(TouchStartEvent event) { event.preventDefault(); event.stopPropagation(); if (event.getTouches().length() > 0) { Touch t = event.getTouches().get(0); lastX = t.getClientX(); lastY = t.getClientY(); fingerDownAt = new Date().getTime(); if (isDoLog()) addToLog("startTouch", "cursorX=\"" + x + "\" cursorY=\"" + y + "\"", null); if (!move) { downSent = false; if (dragModeEnabled) mouseDownTimer.schedule(MOUSEDOWNTHRESHOLD); } } }
From source file:com.fullmetalgalaxy.client.widget.WgtScroll.java
License:Open Source License
@Override public void onTouchStart(TouchStartEvent p_event) { Touch touch = getTouch(p_event.getChangedTouches(), -1); if (touch != null) { m_currentTouchEventId = touch.getIdentifier(); onDown(Element.as(touch.getTarget()), touch.getClientX(), touch.getClientY()); }/*from w ww . j av a 2 s . c om*/ }
From source file:com.fullmetalgalaxy.client.widget.WgtScroll.java
License:Open Source License
@Override public void onTouchMove(TouchMoveEvent p_event) { Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId); if (touch != null) { if (p_event.getTouches().length() < 2) { // A single finger touch shouldn't be propagated upwards. // This prevents iOS 'bounce-scroll' to happen p_event.preventDefault();//from w w w . ja v a 2 s . c om } onMove(Element.as(touch.getTarget()), touch.getClientX(), touch.getClientY()); } }
From source file:com.googlecode.mgwt.dom.client.event.touch.TouchCopy.java
License:Apache License
public TouchCopy(Touch touch) { this.pageX = touch.getPageX(); this.pageY = touch.getPageY(); this.clientX = touch.getClientX(); this.clientY = touch.getClientY(); this.screenX = touch.getScreenX(); this.screenY = touch.getScreenY(); this.id = touch.getIdentifier(); }
From source file:com.milmaps.client.MapTouchController.java
License:Open Source License
private void maybeShowBubble(final Touch touch) { GeodeticCoords gc = touchToGeo(touch); int level = m_mapView.getDivManager().getCurrentLevel(); double lat = gc.getPhi(AngleUnit.DEGREES); double lng = gc.getLambda(AngleUnit.DEGREES); m_reader.getFeatures(level, lat, lng, new AsyncCallback<List<Feature>>() { @Override/* w w w. j a v a2s . c om*/ public void onSuccess(List<Feature> result) { if (result.size() > 0) { m_bubbleControl.hide(); String titles = ""; for (Feature feature : result) { titles += feature.getTitle() + "<br/>"; } m_bubbleControl.getHtml().setHTML(titles); m_bubbleControl.show(touch.getClientX(), touch.getClientY() - 20); } else { m_bubbleControl.hide(); } } @Override public void onFailure(Throwable caught) { Window.alert("failure"); } }); }
From source file:com.sencha.gxt.sample.graph.client.draw.GraphDnD.java
License:Apache License
protected void onTouchMove(Event e) { JsArray<Touch> touches = e.getChangedTouches(); for (int i = 0; i < touches.length(); i++) { Touch t = touches.get(i); if (!touchDragStartPositions.containsKey(t.getIdentifier())) { //not an active drag continue; }//from w w w . j a va2 s. co m //TODO fire an event about the move int x = t.getClientX() - graph.getElement().getAbsoluteTop() + graph.getElement().getScrollTop() + graph.getElement().getOwnerDocument().getScrollTop(); int y = t.getClientY() - graph.getElement().getAbsoluteLeft() + graph.getElement().getScrollLeft() + graph.getElement().getOwnerDocument().getScrollLeft(); touchLastDragPositions.put(t.getIdentifier(), new Point(x, y)); //TODO consider getting the offset from the original mouse point to the object // and using that here onDrag("touch" + t.getIdentifier(), x, y); e.preventDefault(); // log.finer("Touch move: " + t.getIdentifier() + " @ " + lastDragPosition.get(t.getIdentifier()).toString()); } }
From source file:com.sencha.gxt.widget.core.client.event.XEvent.java
License:sencha.com license
/** * Returns the mouse/touch location.//from w ww. j av a2s .com * * @return the mouse/touch location */ public final Point getXY() { if (getChangedTouches() != null) { // touch event Touch touch = getChangedTouches().get(0); return new Point(touch.getClientX(), touch.getClientY()); } return new Point(getClientX(), getClientY()); }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); if (!isEnabled()) return;//from w w w. j a v a2 s.c om final Element targetElem = EventUtil.getTargetElem(event); if (targetElem != null) { final Element element; final JsArray<Touch> touches; final int clientX, clientY; final boolean wasContextClickFired; switch (event.getTypeInt()) { case Event.ONMOUSEDOWN: onStart(event, null); break; case Event.ONTOUCHSTART: touches = event.getTouches(); if (touches.length() == 1 && touchIdentifier == null) { onStart(event, touches.get(0)); } else { // Another finger is touching the screen. onEnd(event); } break; case Event.ONMOUSEMOVE: if (touchActive) { clientX = event.getClientX(); clientY = event.getClientY(); if (Math.abs(touchPointX - clientX) >= 10 || Math.abs(touchPointY - clientY) >= 10) { onEnd(event); } } break; case Event.ONTOUCHMOVE: if (touchActive) { touches = event.getTouches(); if (touches.length() == 1 && touchIdentifier != null) { final Touch touch = touches.get(0); if (touch.getIdentifier() == touchIdentifier.intValue()) { clientX = touch.getClientX(); clientY = touch.getClientY(); if (Math.abs(touchPointX - clientX) >= 10 || Math.abs(touchPointY - clientY) >= 10) { onEnd(event); } } } } break; case Event.ONMOUSEUP: case Event.ONMOUSEOUT: case Event.ONTOUCHEND: case Event.ONTOUCHCANCEL: element = activeElement; wasContextClickFired = contextClickFired; onEnd(event); if (element != null && wasContextClickFired) { onClick(element, null); } break; case Event.ONCLICK: if (!isEnabled()) return; element = _findElement(event); onClick(element, targetElem); break; case Event.ONCONTEXTMENU: if (!isEnabled()) return; element = _findElement(event); if (element != null) { // Find the "context clickable element". // The context clickable element is the title element, unless there // is no title element, in which case it is the <li>. Element contextClickableElement = element; final NodeList<Node> children = element.getChildNodes(); final int children_length = children.getLength(); for (int i = 0; i < children_length; ++i) { final Node child = children.getItem(i); if (child.getNodeType() != Node.ELEMENT_NODE) continue; final Element childElem = (Element) child; if (ElementUtil.hasClassName(childElem, TableView.RECORD_TITLE_CLASS_NAME)) { contextClickableElement = childElem; if (touchActive) contextClickFired = true; break; } } if (contextClickableElement.isOrHasChild(targetElem)) { final Integer recordIndex = _findRecordIndex(element); if (recordIndex != null) { final Record record = _getData().get(recordIndex.intValue()); final boolean cancelled = RowContextClickEvent._fire(this, -1, record, recordIndex.intValue()); if (!cancelled) { final Menu contextMenu = getContextMenu(); if (contextMenu != null) { contextClickableElement.addClassName(_CSS.contextClickedElementClass()); final Object recordID = getRecordId(record); final Element li = elementMap.get(recordID); assert li != null; final Element finalContextClickableElement = contextClickableElement; new BeforeMenuHiddenHandler() { private HandlerRegistration beforeMenuHiddenRegistration = contextMenu ._addBeforeMenuHiddenHandler(this); @Override public void _onBeforeMenuHidden(BeforeMenuHiddenEvent event) { beforeMenuHiddenRegistration.removeHandler(); finalContextClickableElement .removeClassName(_CSS.contextClickedElementClass()); } }; contextMenu._showAt(this, event.getClientX(), event.getClientY(), contextClickableElement.getAbsoluteLeft(), contextClickableElement.getAbsoluteRight(), contextClickableElement.getAbsoluteTop(), contextClickableElement.getAbsoluteBottom()); if (touchActive) contextClickFired = true; break; } } } } } break; } } }