private void OnMouseMove(object sender, NativeWindowMouseEventArgs e) { if (e.Buttons == MouseButton.Right) { _touchProcessor.OnPointerMove(e.Location.X, e.Location.Y, 1); } else { _touchProcessor.OnMouseHover(e.Location.X, e.Location.Y, 1); } }
/// <summary> /// This function handles touch events. /// It is responsible for maintaining the currently active touch events and dispatching events. /// For details see http://developer.android.com/reference/android/view/View.html#onTouchEvent(android.view.MotionEvent) /// </summary> public override bool OnTouchEvent(MotionEvent e) { float xConversion = SparrowSharp.Stage.StageWidth / Width; float yConversion = SparrowSharp.Stage.StageHeight / Height; // get pointer index from the event object int pointerIndex = e.ActionIndex; // get pointer ID int pointerId = e.GetPointerId(pointerIndex); // get masked (not specific to a pointer) action MotionEventActions maskedAction = e.ActionMasked; switch (maskedAction) { case MotionEventActions.Down: case MotionEventActions.PointerDown: touchProcessor.OnPointerDown(e.GetX() * xConversion, e.GetY() * yConversion, pointerId); break; case MotionEventActions.Move: for (int size = e.PointerCount, i = 0; i < size; i++) { touchProcessor.OnPointerMove(e.GetX(i) * xConversion, e.GetY(i) * yConversion, e.GetPointerId(i)); } break; case MotionEventActions.Up: case MotionEventActions.PointerUp: touchProcessor.OnPointerUp(pointerId); break; case MotionEventActions.Cancel: touchProcessor.OnPointerUp(pointerId); break; } return(true); }