public override bool onTouchEvent(MotionEvent @event) { // assembly: Y:\staging\clr\PopupWebView.AndroidActivity.dll // type: PopupWebView.Library.XWindow, PopupWebView.AndroidActivity, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null //offset: // 0x0083 // method: Boolean onInterceptTouchEvent(android.view.MotionEvent) } // script: error JSC1000: Java : unable to emit and at 'PopupWebView.Library.XWindow.onInterceptTouchEvent'#0085: multiple stack entries instead of one // handle touching outside if (@event.getAction() == MotionEvent.ACTION_OUTSIDE) { // unfocus window if (mContext.getFocusedWindow() == this) { mContext.unfocus(this); } // notify implementation that ACTION_OUTSIDE occurred mContext.onTouchBody(id, this, this, @event); } // handle multitouch if (@event.getPointerCount() >= 2 && XUtils.isSet(flags, XStandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE)) { // 2 fingers or more float x0 = @event.getX(0); float y0 = @event.getY(0); float x1 = @event.getX(1); float y1 = @event.getY(1); double dist = System.Math .Sqrt(System.Math.Pow(x0 - x1, 2) + System.Math.Pow(y0 - y1, 2)); if ((@event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_MOVE) { if (touchInfo.dist == -1) { touchInfo.dist = dist; } touchInfo.scale *= dist / touchInfo.dist; touchInfo.dist = dist; // scale the window with anchor point set to middle edit().setAnchorPoint(.5f, .5f) .setSize( (int)(touchInfo.firstWidth * touchInfo.scale), (int)(touchInfo.firstHeight * touchInfo.scale)) .commit(); } mContext.onResize(id, this, this, @event); } return(true); }
public override bool onTouchEvent(MotionEvent e) { if (e != null) { float x = e.getX(); float y = e.getY(); var MotionEvent_ACTION_MOVE = 7; if (e.getAction() == MotionEvent_ACTION_MOVE) { float deltaX = (x - mPreviousX) / mDensity / 2f; float deltaY = (y - mPreviousY) / mDensity / 2f; if (ontouchmove != null) { ontouchmove(deltaX, deltaY); } //mRenderer.mDeltaX += deltaX; //mRenderer.mDeltaY += deltaY; } mPreviousX = x; mPreviousY = y; return(true); } return(base.onTouchEvent(e)); }
public override bool onTouchEvent(MotionEvent e) { if (e != null) { float x = e.getX(); float y = e.getY(); var MotionEvent_ACTION_MOVE = 7; if (e.getAction() == MotionEvent_ACTION_MOVE) { float deltaX = (x - mPreviousX) / mDensity / 2f; float deltaY = (y - mPreviousY) / mDensity / 2f; if (ontouchmove != null) ontouchmove(deltaX, deltaY); //mRenderer.mDeltaX += deltaX; //mRenderer.mDeltaY += deltaY; } mPreviousX = x; mPreviousY = y; return true; } return base.onTouchEvent(e); }
/// <summary>Handles touch events for dragging.</summary> /// <remarks> /// Handles touch events for dragging. You may want to do other actions /// like moving the cursor on touch as well. /// </remarks> public static bool onTouchEvent(TextView widget, Spannable buffer, MotionEvent @event) { DragState[] ds; switch (@event.getActionMasked()) { case MotionEvent.ACTION_DOWN: { ds = buffer.getSpans <DragState> (0, buffer.Length); { for (int i = 0; i < ds.Length; i++) { buffer.removeSpan(ds [i]); } } buffer.setSpan(new DragState(@event.getX(), @event.getY(), widget.getScrollX(), widget.getScrollY()), 0, 0, SpannedClass.SPAN_MARK_MARK); return(true); } case MotionEvent.ACTION_UP: { ds = buffer.getSpans <DragState> (0, buffer.Length); { for (int i_1 = 0; i_1 < ds.Length; i_1++) { buffer.removeSpan(ds [i_1]); } } if (ds.Length > 0 && ds [0].mUsed) { return(true); } else { return(false); } goto case MotionEvent.ACTION_MOVE; } case android.view.MotionEvent.ACTION_MOVE: { ds = buffer.getSpans <Touch.DragState> (0, buffer.Length); if (ds.Length > 0) { if (ds [0].mFarEnough == false) { int slop = ViewConfiguration.get(widget.getContext()).getScaledTouchSlop(); if (Math.Abs(@event.getX() - ds [0].mX) >= slop || Math.Abs(@event.getY() - ds [0].mY) >= slop) { ds [0].mFarEnough = true; } } if (ds [0].mFarEnough) { ds [0].mUsed = true; bool cap = (@event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0 || MetaKeyKeyListener.getMetaState(buffer, MetaKeyKeyListener.META_SHIFT_ON) == 1 || MetaKeyKeyListener.getMetaState(buffer, MetaKeyKeyListener.META_SELECTING) != 0; float dx; float dy; if (cap) { // if we're selecting, we want the scroll to go in // the direction of the drag dx = @event.getX() - ds [0].mX; dy = @event.getY() - ds [0].mY; } else { dx = ds [0].mX - @event.getX(); dy = ds [0].mY - @event.getY(); } ds [0].mX = @event.getX(); ds [0].mY = @event.getY(); int nx = widget.getScrollX() + (int)dx; int ny = widget.getScrollY() + (int)dy; int padding = widget.getTotalPaddingTop() + widget.getTotalPaddingBottom(); Layout layout = widget.getLayout(); ny = Math.Min(ny, layout.getHeight() - (widget.getHeight() - padding)); ny = Math.Max(ny, 0); int oldX = widget.getScrollX(); int oldY = widget.getScrollY(); scrollTo(widget, layout, nx, ny); // If we actually scrolled, then cancel the up action. if (oldX != widget.getScrollX() || oldY != widget.getScrollY()) { widget.cancelLongPress(); } return(true); } } return(false); } } return(false); }