/// <summary> /// Called, when mouse/finger/pen tapped on map 2 or more times /// </summary> /// <param name="screenPosition">First clicked/touched position on screen</param> /// <param name="numOfTaps">Number of taps on map (2 is a double click/tap)</param> /// <returns>True, if the event is handled</returns> private bool OnDoubleTapped(Geometries.Point screenPosition, int numOfTaps) { var args = new TappedEventArgs(screenPosition, numOfTaps); DoubleTap?.Invoke(this, args); if (args.Handled) { return(true); } var eventReturn = InvokeInfo(Map.Layers, Map.GetWidgetsOfMapAndLayers(), Viewport, screenPosition, screenPosition, _renderer.SymbolCache, WidgetTouched, numOfTaps); if (eventReturn != null) { if (!eventReturn.Handled) { // Double tap as zoom return(OnZoomIn(screenPosition)); } } return(false); }
public void OnPointerDown(PointerEventData eventData) { if (_clickTime > 0) { if ((Time.realtimeSinceStartup - _clickTime) < 0.3f) { if (_timeRefreshDoubleTap > 5) { DoubleTap?.Invoke(); _timeRefreshDoubleTap = 0; } } else { if (eventData.pressPosition.x > (Camera.main.pixelWidth / 2)) { isRight = true; } else if (eventData.pressPosition.x < (Camera.main.pixelWidth / 2)) { isLeft = true; } } } _clickTime = Time.realtimeSinceStartup; }
private void RaiseDoubleTap(int index) { if (DoubleTap != null) { DoubleTap.Invoke(index); } }
private void TapTimer_Expired() { if (Mode == TouchMode.Normal) { if (TapCount == 1) { Tap?.Invoke(this, null); } else if (TapCount >= 2) { DoubleTap?.Invoke(this, null); } TapCount = 0; } }
/// <summary> /// Called, when mouse/finger/pen tapped on map 2 or more times /// </summary> /// <param name="screenPosition">First clicked/touched position on screen</param> /// <param name="numOfTaps">Number of taps on map (2 is a double click/tap)</param> /// <returns>True, if the event is handled</returns> private bool OnDoubleTapped(Geometries.Point screenPosition, int numOfTaps) { var args = new TappedEventArgs(screenPosition, numOfTaps); DoubleTap?.Invoke(this, args); if (args.Handled) { return(true); } var eventReturn = InvokeInfo(screenPosition, screenPosition, numOfTaps); if (eventReturn?.Handled == true) { return(true); } // Double tap as zoom return(OnZoomIn(screenPosition)); }
/// <summary> /// Called, when mouse/finger/pen tapped on map 2 or more times /// </summary> /// <param name="screenPosition">First clicked/touched position on screen</param> /// <param name="numOfTaps">Number of taps on map (2 is a double click/tap)</param> private bool OnDoubleTapped(Geometries.Point screenPosition, int numOfTaps) { var args = new TappedEventArgs(screenPosition, numOfTaps); DoubleTap?.Invoke(this, args); if (args.Handled) { return(true); } var tapWasHandled = Map.InvokeInfo(screenPosition, screenPosition, _scale, _renderer.SymbolCache, WidgetTouched, numOfTaps); if (!tapWasHandled) { // Double tap as zoom return(OnZoomIn(screenPosition)); } return(false); }
private void OnMouseStuff(object sender, MouseEventArgs args) { if (args.RoutedEvent == UIElement.MouseUpEvent || (args.RoutedEvent == UIElement.MouseLeftButtonDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.MouseMoveEvent && args.Source == null && args.LeftButton == MouseButtonState.Released)) { MultitouchWindow.RemoveMouseListener(_attachedElement, OnMouseStuff); if (!_downpoint.ContainsKey(-1)) { return; } //if (args.OriginalSource != _attachedElement) return; args.Handled = true; Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); Vector jitter = Point.Subtract(current, _downpoint[-1]); if (jitter.Length < Threshold) { if (Tap != null) { Tap.Invoke(_attachedElement, new TapEventArgs(args.MouseDevice, jitter)); } if (args.Timestamp - _lasttap < DoubleTapDelay.TotalMilliseconds && DoubleTap != null) { DoubleTap.Invoke(_attachedElement, new TapEventArgs(args.MouseDevice, jitter)); } if (_attachedElement is Control) { ((Control)_attachedElement).RaiseEvent( new MouseButtonEventArgs(args.MouseDevice, args.Timestamp, ((MouseButtonEventArgs)args).ChangedButton) { RoutedEvent = Control.MouseDoubleClickEvent }); } _lasttap = args.Timestamp; } } else if (args.RoutedEvent == UIElement.MouseDownEvent) { MultitouchWindow.AddMouseListener(_attachedElement, OnMouseStuff); _downpoint[-1] = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); } else if (args.RoutedEvent == UIElement.MouseMoveEvent) { if (!_downpoint.ContainsKey(-1)) { return; } Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); if (Point.Subtract(current, _downpoint[-1]).Length > Threshold) { _downpoint.Remove(-1); } } }
private void OnStylusStuff(object sender, StylusEventArgs args) { if (args.RoutedEvent == UIElement.StylusUpEvent || (args.RoutedEvent == UIElement.StylusDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.StylusMoveEvent && args.Source == null && args.InAir)) { MultitouchWindow.RemoveStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); if (!_downpoint.ContainsKey(args.StylusDevice.Id)) { return; } //if (args.OriginalSource != _attachedElement) return; args.Handled = true; Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); Vector jitter = Point.Subtract(current, _downpoint[args.StylusDevice.Id]); if (jitter.Length < Threshold) { if (Tap != null) { Tap.Invoke(_attachedElement, new TapEventArgs(args.StylusDevice, jitter)); } if (_button != null) { _button.SetValue(TapBehavior.IsPressedProperty, true); _button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); ExecuteCommandSource(_button); } if ((args.Timestamp - _lasttap) < DoubleTapDelay.TotalMilliseconds && DoubleTap != null) { DoubleTap.Invoke(_attachedElement, new TapEventArgs(args.StylusDevice, jitter)); } if (_attachedElement is Control) { ((Control)_attachedElement).RaiseEvent( new MouseButtonEventArgs(Mouse.PrimaryDevice, args.Timestamp, MouseButton.Left, args.StylusDevice) { RoutedEvent = Control.MouseDoubleClickEvent }); } _lasttap = args.Timestamp; } } else if (args.RoutedEvent == UIElement.StylusDownEvent) { MultitouchWindow.AddStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); _downpoint[args.StylusDevice.Id] = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); if (_button != null) { _button.SetValue(TapBehavior.IsPressedProperty, true); } } else if (args.RoutedEvent == UIElement.StylusMoveEvent) { if (!_downpoint.ContainsKey(args.StylusDevice.Id)) { return; } Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); if (Point.Subtract(current, _downpoint[args.StylusDevice.Id]).Length > Threshold) { _downpoint.Remove(args.StylusDevice.Id); if (_button != null) { _button.SetValue(TapBehavior.IsPressedProperty, false); } } } }