internal virtual void OnPointerPressedInternal(object sender, PointerRoutedEventArgs args) { if (!args.Handled) { PointerPressed?.Invoke(sender, args); } }
internal void ProcessTouch(string actionType, XPointerEventArgs args) { switch (actionType) { case "Cancelled": PointerLost?.Invoke(this, args); break; case "Entered": PointerEntered?.Invoke(this, args); break; case "Exited": PointerExited?.Invoke(this, args); break; case "Moved": PointerMoved?.Invoke(this, args); break; case "Pressed": PointerPressed?.Invoke(this, args); break; case "Released": PointerReleased?.Invoke(this, args); break; } }
public override void TouchesBegan(NSSet touches, UIEvent evt) { if (evt.IsTouchInView(this)) { PointerPressed?.Invoke(this, new PointerRoutedEventArgs()); } }
protected override bool OnDown(MotionEvent e) { try { var args = GetPointerEventArgs(e, 0); PointerPressed?.Invoke(Target, args); return(args.Handled); } catch (Exception ex) { Windows.UI.Xaml.Application.Current.RaiseRecoverableUnhandledExceptionOrLog(ex, this); return(false); } }
private void PointerDetectUIElement_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { PointerPoint win10PointerPoint = e.GetCurrentPoint(PointerDetectUIElement); lock (PointerDictLock) { if (PointerDict.ContainsKey(win10PointerPoint.PointerId)) { RXPointer pointer = PointerDict[win10PointerPoint.PointerId] as RXPointer; pointer.UpdatePointer(win10PointerPoint, PointerState.Pressed); PointerPressed?.Invoke(this, pointer); } else { throw new NotImplementedException(); } } }
/// <summary> /// Handle every mouse click, touch screen tap, or equivalent interaction. /// Used to detect browser-style next and previous mouse button clicks to navigate between pages. /// By defualt the 2 mouse keys work like the broswer, ovveride to implement your own logic. /// Make sure you are not handling the event (Window.Current.CoreWindow.PointerPressed) yourself for the service to function correctly. /// </summary> /// <param name="sender">Instance that triggered the event.</param> /// <param name="args">Event data describing the conditions that led to the event.</param> protected virtual void OnPointerPressed(CoreWindow sender, PointerEventArgs args) { args.Handled = false; // I noticed handled always comes true for some reason, so since we are the first we set it to false. PointerPressed?.Invoke(sender, args); if (args.Handled) { return; } var properties = args.CurrentPoint.Properties; // Ignore button chords with the left, right, and middle buttons if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed || properties.IsMiddleButtonPressed) { return; } // If back or foward are pressed (but not both) navigate appropriately bool backPressed = properties.IsXButton1Pressed; bool forwardPressed = properties.IsXButton2Pressed; if (backPressed ^ forwardPressed) { args.Handled = true; if (backPressed) { RaiseGoBackRequested(sender); } if (forwardPressed) { RaiseGoForwardRequested(sender); } } }
void ICoreWindowEvents.RaisePointerPressed(PointerEventArgs args) => PointerPressed?.Invoke(this, args);
public bool OnTouch(MotionEvent e) { int pointerIndex = ((int)(e.Action & MotionEventActions.PointerIndexMask)) >> ((int)(MotionEventActions.PointerIndexShift)); int pointerId = e.GetPointerId(pointerIndex); int down = (int)(e.ActionMasked & MotionEventActions.PointerDown); int up = (int)(e.ActionMasked & MotionEventActions.PointerUp); switch (e.ActionMasked) { case MotionEventActions.Down: case MotionEventActions.PointerDown: { /* * Touch touch = new Touch(pointerId); * touch.Position = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex)); * _Touches.Add(pointerId, touch); * OnTouchAction?.Invoke(touch, TouchMotionAction.Down); */ if (PointerDict.ContainsKey(pointerId)) //这种情况多半是我在进入断点后把手移开了,就当是释放了手指就好了吧 { //throw new NotImplementedException(); Pointer pointer = PointerDict[pointerId]; Vector2 pos = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex)); pointer.UpdatePointer(PointerState.Released); PointerReleased?.Invoke(this, pointer); pointer.UpdatePointer(PointerState.Exited); PointerDict.Remove(pointerId); PointerExited?.Invoke(this, pointer); } else { Pointer pointer = new Pointer(this, pointerId); Vector2 pos = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex)); pointer.UpdatePointer(pos, PointerState.Entered); PointerDict.Add(pointerId, pointer); PointerEntered?.Invoke(this, pointer); pointer.UpdatePointer(pos, PointerState.Pressed); PointerPressed?.Invoke(this, pointer); //Log.Info(TAG, "DOWN:" + pointer.ToString()); } break; } case MotionEventActions.Up: case MotionEventActions.PointerUp: { //Touch touch = _Touches[pointerId]; //_Touches.Remove(pointerId); //OnTouchAction?.Invoke(touch, TouchMotionAction.Up); if (PointerDict.ContainsKey(pointerId)) { Pointer pointer = PointerDict[pointerId]; Vector2 pos = new Vector2(e.GetX(pointerIndex), e.GetY(pointerIndex)); pointer.UpdatePointer(PointerState.Released); PointerReleased?.Invoke(this, pointer); pointer.UpdatePointer(PointerState.Exited); PointerDict.Remove(pointerId); PointerExited?.Invoke(this, pointer); //Log.Info(TAG, "UP:" + pointer.ToString()); } else { //throw new NotImplementedException(); } break; } case MotionEventActions.Move: { foreach (var pair in PointerDict) { int pIndex = e.FindPointerIndex(pair.Key); if (pIndex < 0) { continue; } Vector2 currentPos = new Vector2(e.GetX(pIndex), e.GetY(pIndex)); if (pair.Value.PointerPoint != currentPos) { //pair.Value.PointerPoint = currentPos; pair.Value.UpdatePointer(currentPos); PointerMoved?.Invoke(this, pair.Value); //Log.Info(TAG, "MOVE:" + pair.Value.ToString()); } } break; } } return(true); }
protected override void Update() { base.Update(); lock (_SketchPointersReadyToEnterLock) { SketchPointersList.AddRange(_SketchPointersReadyToEnter); _SketchPointersReadyToEnter.Clear(); } Queue <PointerInfoCache> cacheQueue; lock (_PointerInfoCachesLock) { cacheQueue = new Queue <PointerInfoCache>(_PointerInfoCaches); _PointerInfoCaches.Clear(); } while (cacheQueue.Count != 0) { PointerInfoCache cache = cacheQueue.Dequeue(); if (cache.CacheEvent == PointerInfoCacheEvent.Moved) { cache.HitLayer = cache.SketchPointer.LatestPointerInfoCache.HitLayer; } cache.SketchPointer.LatestPointerInfoCache = cache; if (cache.CacheEvent == PointerInfoCacheEvent.Pressed) { foreach (var sketchObject in SketchEngine.SketchObjectList) { if (sketchObject is IInputComponent) { if ((sketchObject as IInputComponent).StartRegion.IsOverlapPoint(cache.SketchPointer.Point)) { cache.HitLayer = (sketchObject as IInputComponent).Level; break; } } } cache.SketchPointer.LatestPointerInfoCache = cache; } switch (cache.CacheEvent) { case PointerInfoCacheEvent.Entered: PointerEntered?.Invoke(this, cache.SketchPointer); break; case PointerInfoCacheEvent.Pressed: PointerPressed?.Invoke(this, cache.SketchPointer); break; case PointerInfoCacheEvent.Moved: PointerMoved?.Invoke(this, cache.SketchPointer); break; case PointerInfoCacheEvent.Released: PointerReleased?.Invoke(this, cache.SketchPointer); break; case PointerInfoCacheEvent.Exited: PointerExited?.Invoke(this, cache.SketchPointer); break; } } lock (_SketchPointersReadyToExitLock) { foreach (var readyToExtiPointer in _SketchPointersReadyToExit) { SketchPointersList.Remove(readyToExtiPointer); } _SketchPointersReadyToExit.Clear(); } }