private void OnPanelPointerPressed(object sender, Input.PointerRoutedEventArgs args) { // Both pressed & released must reach // the popup to close it. // (and, obviously, the popup must be light dismiss!) _pressed = IsLightDismissEnabled; }
private void HandlePointerEvent(Input.PointerRoutedEventArgs e) { var(clientSize, offsetSize) = WindowManagerInterop.GetClientViewSize(HtmlId); bool hasHorizontalScroll = (offsetSize.Height - clientSize.Height) > 0; bool hasVerticalScroll = (offsetSize.Width - clientSize.Width) > 0; if (this.Log().IsEnabled(LogLevel.Debug)) { this.Log().LogDebug($"{HtmlId}: {offsetSize} / {clientSize} / {e.GetCurrentPoint(this)}"); } if (!hasVerticalScroll && !hasHorizontalScroll) { return; } // The events coming from the scrollbars are bubbled up // to the parents, as those are not (yet) XAML elements. // This can cause issues for popups with scrollable content and // light dismiss patterns. var position = e.GetCurrentPoint(this).Position; var isInVerticalScrollbar = hasVerticalScroll && position.X >= clientSize.Width; var isInHorizontalScrollbar = hasHorizontalScroll && position.Y >= clientSize.Height; if (isInVerticalScrollbar || isInHorizontalScrollbar) { e.Handled = true; } }
private void ScrollContentPresenter_PointerWheelChanged(object sender, Input.PointerRoutedEventArgs e) { var properties = e.GetCurrentPoint(null).Properties; if (Content is UIElement) { var canScrollHorizontally = CanHorizontallyScroll; var canScrollVertically = CanVerticallyScroll; if (e.KeyModifiers == VirtualKeyModifiers.Control) { // TODO: Handle zoom https://github.com/unoplatform/uno/issues/4309 } else if (!canScrollVertically || properties.IsHorizontalMouseWheel || e.KeyModifiers == VirtualKeyModifiers.Shift) { if (canScrollHorizontally) { SetHorizontalOffset(HorizontalOffset + GetHorizontalScrollWheelDelta(DesiredSize, -properties.MouseWheelDelta * ScrollViewerDefaultMouseWheelDelta)); } } else { SetVerticalOffset(VerticalOffset + GetVerticalScrollWheelDelta(DesiredSize, properties.MouseWheelDelta * ScrollViewerDefaultMouseWheelDelta)); } } }
private void ScrollContentPresenter_PointerWheelChanged(object sender, Input.PointerRoutedEventArgs e) { var properties = e.GetCurrentPoint(null).Properties; if (Content is UIElement c) { if (properties.IsHorizontalMouseWheel) { HorizontalOffset += GetHorizontalScrollWheelDelta(c.RenderSize, properties.MouseWheelDelta); } else { VerticalOffset += GetVerticalScrollWheelDelta(c.RenderSize, properties.MouseWheelDelta); } c.RenderTransform = new TranslateTransform() { X = -HorizontalOffset, Y = -VerticalOffset }; Window.Current.QueueInvalidateRender(); } (TemplatedParent as ScrollViewer)?.OnScrollInternal(HorizontalOffset, VerticalOffset, false); }
private void DragDropTarget_PointerMoved(object sender, Input.PointerRoutedEventArgs e) #endif { //---------------------------------- // POINTER MOVE //---------------------------------- if (_isPointerCaptured) { // Calculate the delta of the movement: #if MIGRATION double horizontalChange = e.GetPosition(null).X - _pointerX; double verticalChange = e.GetPosition(null).Y - _pointerY; #else double horizontalChange = e.GetCurrentPoint(null).Position.X - _pointerX; double verticalChange = e.GetCurrentPoint(null).Position.Y - _pointerY; #endif // Remember the new pointer position: #if MIGRATION _pointerX = e.GetPosition(null).X; _pointerY = e.GetPosition(null).Y; #else _pointerX = e.GetCurrentPoint(null).Position.X; _pointerY = e.GetCurrentPoint(null).Position.Y; #endif // Move the popup and may raise the events DragEnter, DragOver and DragLeave: MovePopupAndRaiseEvents(horizontalChange, verticalChange); } }
private void ScrollContentPresenter_PointerWheelChanged(object sender, Input.PointerRoutedEventArgs e) { var properties = e.GetCurrentPoint(null).Properties; if (Content is UIElement) { var canScrollHorizontally = HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled; var canScrollVertically = VerticalScrollBarVisibility != ScrollBarVisibility.Disabled; if (e.KeyModifiers == global::Windows.System.VirtualKeyModifiers.Control) { // TODO: Handle zoom } else if (!canScrollVertically || properties.IsHorizontalMouseWheel || e.KeyModifiers == global::Windows.System.VirtualKeyModifiers.Shift) { if (canScrollHorizontally) { SetHorizontalOffset(HorizontalOffset + GetHorizontalScrollWheelDelta(DesiredSize, -properties.MouseWheelDelta * ScrollViewerDefaultMouseWheelDelta)); } } else { SetVerticalOffset(VerticalOffset + GetVerticalScrollWheelDelta(DesiredSize, properties.MouseWheelDelta * ScrollViewerDefaultMouseWheelDelta)); } } }
private void Panel_PointerPressed(object sender, Input.PointerRoutedEventArgs e) { if (IsLightDismissEnabled) { IsOpen = false; } }
private void PopupRoot_PointerReleased(object sender, Input.PointerRoutedEventArgs e) { Children.Select(GetPopup) .Where(p => p.IsLightDismissEnabled) .ToList() .ForEach(p => p.IsOpen = false); }
void DragDropTarget_PointerReleased(object sender, Input.PointerRoutedEventArgs e) #endif { //---------------------------------- // POINTER RELEASED //---------------------------------- // Remember the new pointer position: #if MIGRATION _pointerX = e.GetPosition(null).X; _pointerY = e.GetPosition(null).Y; #else _pointerX = e.GetCurrentPoint(null).Position.X; _pointerY = e.GetCurrentPoint(null).Position.Y; #endif if (_isPointerCaptured && e.Pointer == _capturedPointer) { // We call MovePopupAndRaiseEvents(0,0) to prevent fast click, move and release of the mouse doing unwanted behavior (bug in case that the buttonup event was triggered before mousemove event) MovePopupAndRaiseEvents(0, 0); // Stop capturing the pointer: _isPointerCaptured = false; #if MIGRATION this.ReleaseMouseCapture(); #else this.ReleasePointerCapture(_capturedPointer); #endif // Handle the drop: OnDropped(e); } }
protected override void OnPointerPressed(Input.PointerRoutedEventArgs eventArgs) #endif { //if (IsPressed && ClickMode != ClickMode.Hover) //{ StartTimer(); //} //-------------------------------------------------------------------------- // Note: it is important that the code below ("base.OnPointerPressed")is executed AFTER the code above, otherwise // it will not work properly. In fact, you can reproduce the issue in case of inverted order by creating two // NumericUpDown controls, and using the following code-behind: // private void Numeric2_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) // { // if (Numeric1.Value + Numeric2.Value > 1) // { // Numeric2.Value = 0; // MessageBox.Show("Exceeded"); // } // } // You will then notice that there is an infinite number of message boxes. //-------------------------------------------------------------------------- #if MIGRATION base.OnMouseLeftButtonDown(eventArgs); #else base.OnPointerPressed(eventArgs); #endif }
void Thumb_PointerPressed(object sender, Input.PointerRoutedEventArgs e) #endif { // Remember the current pointer position: #if MIGRATION _pointerX = e.GetPosition(null).X; _pointerY = e.GetPosition(null).Y; #else _pointerX = e.GetCurrentPoint(null).Position.X; _pointerY = e.GetCurrentPoint(null).Position.Y; #endif // Capture the pointer so that when dragged outside the thumb, we can still get its position: #if MIGRATION this.CaptureMouse(); #else this.CapturePointer(e.Pointer); #endif // Remember that the pointer is currently captured: _isPointerCaptured = true; _capturedPointer = e.Pointer; // Set the "IsDragging" dependency property: this.IsDragging = true; // Raise the "DragStarted" event: if (DragStarted != null) { DragStarted(this, new DragStartedEventArgs(_pointerX, _pointerY)); } }
void Thumb_PointerMoved(object sender, Input.PointerRoutedEventArgs e) #endif { if (_isPointerCaptured) { // Calculate the delta of the movement: #if MIGRATION double horizontalChange = e.GetPosition(null).X - _pointerX; double verticalChange = e.GetPosition(null).Y - _pointerY; #else double horizontalChange = e.GetCurrentPoint(null).Position.X - _pointerX; double verticalChange = e.GetCurrentPoint(null).Position.Y - _pointerY; #endif // Raise the "DragDelta" event: if (DragDelta != null) { DragDelta(this, new DragDeltaEventArgs(horizontalChange, verticalChange)); } // Remember the new pointer position: #if MIGRATION _pointerX = e.GetPosition(null).X; _pointerY = e.GetPosition(null).Y; #else _pointerX = e.GetCurrentPoint(null).Position.X; _pointerY = e.GetCurrentPoint(null).Position.Y; #endif } }
void Thumb_PointerReleased(object sender, Input.PointerRoutedEventArgs e) #endif { if (_isPointerCaptured && e.Pointer == _capturedPointer) { CancelDrag(); } }
private void OnPanelPointerReleased(object sender, Input.PointerRoutedEventArgs args) { if (_pressed && IsLightDismissEnabled) { // Received the completed sequence // pressed + released: we can close. IsOpen = false; } }
private void OnPointerMoved(object sender, Input.PointerRoutedEventArgs e) { if (e.Pointer.PointerDeviceType == PointerDeviceType.Touch) { // Prevent PointerMoved being called on parent, as on UWP. // Note: We only want to do this if the ScrollViewer is actually scrollable (in any direction), but at present on Android // PointerMoved is only raised if content is scrollable - presumably because it's in this case that the inner // NativeScrollContentPresenter 'blocks' the touch according to Uno's pointer logic. e.Handled = true; } }
private void PopupRoot_PointerReleased(object sender, Input.PointerRoutedEventArgs e) { var x = Children.ToArray().FirstOrDefault(); var lastDismissablePopupPanel = Children .OfType <PopupPanel>() .LastOrDefault(p => p.Popup.IsLightDismissEnabled); if (lastDismissablePopupPanel != null) { lastDismissablePopupPanel.Popup.IsOpen = false; } }
protected override void OnPointerReleased(Input.PointerRoutedEventArgs eventArgs) #endif { #if MIGRATION base.OnMouseLeftButtonUp(eventArgs); #else base.OnPointerReleased(eventArgs); #endif //if (ClickMode != ClickMode.Hover) //{ StopTimer(); //} }
void Control_PointerReleased(object sender, Input.PointerRoutedEventArgs e) #endif { _isPressed = false; UpdateVisualStates(); }
void Control_PointerExited(object sender, Input.PointerRoutedEventArgs e) #endif { _isPointerOver = false; UpdateVisualStates(); }
private void ScrollContentPresenter_PointerCanceled(object sender, Input.PointerRoutedEventArgs e) => HandlePointerEvent(e);
private void ScrollViewer_PointerReleased(object sender, Input.PointerRoutedEventArgs e) => HandlePointerEvent(e);
private void OnTap(object sender, Input.PointerRoutedEventArgs e) => e.Handled = true;
private void window_PointerPressed(object sender, Input.PointerRoutedEventArgs e) { Console.WriteLine($"{e.Source}({e.OriginalSource}) : {e.RoutedEvent.Name}"); e.Handled = true; }