public static int GetPointerIndex(MotionEventActions action) { if ((int)Android.OS.Build.VERSION.SdkInt >= (int)Android.OS.Build.VERSION_CODES.Honeycomb) return GetPointerIndexHoneyComb(action); else return GetPointerIndexEclair(action); }
public GestureMotionEvent(MotionEvent e) { _cachedAction = e.Action; _cachedX = e.GetX (); _cachedY = e.GetY (); MotionEvent = e; }
public void HandleTouchEvent(Button b, MotionEventActions action) { var key = Convert.ToInt32(b.Text, 16); keyboardMap[key] = action == MotionEventActions.Down; if (action == MotionEventActions.Down) autoResetEvent.Set(); }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent (MotionEventActions actionCode, MotionEvent e) { if (e.PointerCount > 1) { switch (actionCode) { case MotionEventActions.PointerDown: // At least the second finger is on the screen now. ResetState(); _previousEvent = MotionEvent.Obtain(e); _timeDelta = 0; UpdateStateByEvent(e); // See if we have a sloppy gesture. _sloppyGesture = this.IsSloppyGesture(e); if (!_sloppyGesture) { // No, start gesture now. _gestureInProgress = _listener.OnRotateBegin(this); } break; case MotionEventActions.Move: if (!_sloppyGesture) { break; } // See if we still have a sloppy gesture _sloppyGesture = this.IsSloppyGesture(e); if (!_sloppyGesture) { _gestureInProgress = _listener.OnRotateBegin(this); } break; case MotionEventActions.PointerUp: if (!_sloppyGesture) { break; } break; } } else { // the gesture has to stop! _gestureInProgress = false; _listener.OnRotateEnd(this); ResetState(); } }
protected internal override void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent evt) { switch (actionCode) { case MotionEventActions.PointerDown: { // At least the second finger is on screen now ResetState(); // In case we missed an UP/CANCEL event mPrevEvent = MotionEvent.Obtain(evt); mTimeDelta = 0; UpdateStateByEvent(evt); // See if we have a sloppy gesture mSloppyGesture = IsSloppyGesture(evt); if (!mSloppyGesture) { // No, start gesture now mGestureInProgress = mListener.OnRotateBegin(this); } break; } case MotionEventActions.Move: { if (!mSloppyGesture) { break; } // See if we still have a sloppy gesture mSloppyGesture = IsSloppyGesture(evt); if (!mSloppyGesture) { // No, start normal gesture now mGestureInProgress = mListener.OnRotateBegin(this); } break; } case MotionEventActions.PointerUp: { if (!mSloppyGesture) { break; } break; } } }
/// <summary> /// Called when the current event occurred when NO gesture is in progress /// yet. The handling in this implementation may set the gesture in progress /// or out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">The event.</param> protected override void HandleStartProgressEvent (MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Down: ResetState (); // In case we missed an UP/CANCEL event _previousEvent = MotionEvent.Obtain (e); _timeDelta = 0; UpdateStateByEvent (e); break; case MotionEventActions.Move: _gestureInProgress = _listener.OnMoveBegin(this); break; } }
protected internal override void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent evt) { switch (actionCode) { case MotionEventActions.Down: { ResetState(); // In case we missed an UP/CANCEL event mPrevEvent = MotionEvent.Obtain(evt); mTimeDelta = 0; UpdateStateByEvent(evt); break; } case MotionEventActions.Move: { mGestureInProgress = mListener.OnMoveBegin(this); break; } } }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">The event.</param></param> protected abstract void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent e);
private void SendFakeEvent(MotionEvent e, MotionEventActions forcedAction) { var fake_event = MotionEvent.ObtainNoHistory(e); fake_event.Action = forcedAction; ContentView.ForceHandleTouchEvent(fake_event); fake_event.Recycle(); }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Up: case MotionEventActions.Cancel: if (_tapPeriod > (e.EventTime - _firstEventTime)) { _listener.OnTap(this); ResetState(); } break; case MotionEventActions.Move: if (_tapPeriod < (e.EventTime - _firstEventTime)) { ResetState(); } break; } }
/// <summary> /// Called when the current event occurred when NO gesture is in progress /// yet. The handling in this implementation may set the gesture in progress /// or out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">The event.</param> protected override void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Down: ResetState (); // In case we missed an UP/CANCEL event _firstEventTime = e.EventTime; _previousEvent = MotionEvent.Obtain (e); _timeDelta = 0; _gestureInProgress = true; _x = e.GetX(); _y = e.GetY(); UpdateStateByEvent (e); break; case MotionEventActions.Move: break; } }
protected internal abstract override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent evt);
public override bool OnTouchEvent(MotionEvent e) { MotionEventActions action = e.Action; if (action == MotionEventActions.Up) { float cx = e.RawX; float cy = e.RawY; int x = (int)cx; int y = (int)cy; foreach (KeyValuePair<string, View> eachItem in this.items) { int[] location = new int[2]; eachItem.Value.GetLocationOnScreen(location); int itemWidth = eachItem.Value.Width; int itemHeight = eachItem.Value.Height; if (x > location[0] && x < (location[0] + itemWidth) && y > location[1] && y < (location[1] + itemHeight)) { if (null != this.ItemSelected) { this.ItemSelected(eachItem.Key, eachItem.Value); }//end if break; }//end if }//end foreach }//end if // TODO: Determine what the last action was this.lastTouchAction = action; return base.OnTouchEvent(e); }
private static int GetPointerIndexEclair(MotionEventActions action) { return ((int)action & (int)MotionEventActions.PointerIdMask) >> (int)MotionEventActions.PointerIdShift; }
/// <summary> /// Called when the current event occurred when NO gesture is in progress /// yet. /// </summary> /// <remarks> /// Called when the current event occurred when NO gesture is in progress /// yet. The handling in this implementation may set the gesture in progress /// (via mGestureInProgress) or out of progress /// </remarks> /// <param name="actionCode"></param> /// <param name="event"></param> protected internal abstract void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent evt);
protected internal override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent evt) { switch (actionCode) { case MotionEventActions.PointerUp: { // Gesture ended but UpdateStateByEvent(evt); if (!mSloppyGesture) { mListener.OnRotateEnd(this); } ResetState(); break; } case MotionEventActions.Cancel: { if (!mSloppyGesture) { mListener.OnRotateEnd(this); } ResetState(); break; } case MotionEventActions.Move: { UpdateStateByEvent(evt); // Only accept the event if our relative pressure is within // a certain limit. This can help filter shaky data as a // finger is lifted. if (mCurrPressure / mPrevPressure > PressureThreshold) { bool updatePrevious = mListener.OnRotate(this); if (updatePrevious) { mPrevEvent.Recycle(); mPrevEvent = MotionEvent.Obtain(evt); } } break; } } }
private static int GetPointerIndexHoneyComb(MotionEventActions action) { return ((int)action & (int)MotionEventActions.PointerIndexMask) >> (int)MotionEventActions.PointerIndexShift; }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent (MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Up: case MotionEventActions.Cancel: if (_tapPeriod > (e.EventTime - _firstEventTime) && _xTolerance >= (System.Math.Abs(e.GetX() - _x)) && _yTolerance >= (System.Math.Abs(e.GetY() - _y))) { _listener.OnTap(this); ResetState(); } break; case MotionEventActions.Move: if (_tapPeriod < (e.EventTime - _firstEventTime)) { ResetState(); } break; } }
private MotionEvent ObtainMotionEvent(MotionEvent source, MotionEventActions action) { MotionEvent ev = MotionEvent.ObtainNoHistory(source); ev.Action = action; return ev; }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent (MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Up: case MotionEventActions.Cancel: _listener.OnMoveEnd (this); ResetState (); break; case MotionEventActions.Move: UpdateStateByEvent (e); // Only accept the event if our relative pressure is within // a certain limit. This can help filter shaky data as a // finger is lifted. if (_currentPressure / _previousPressure > PressureThreshold) { bool updatePrevious = _listener.OnMove (this); if (updatePrevious) { _previousEvent.Recycle (); _previousEvent = MotionEvent.Obtain (e); } } break; } }