Просмотр исходного кода

Check if the pointer is within the horizontal bounds of the DraggableTabControl

Ruben 1 неделя назад
Родитель
Сommit
9e08c41bf4
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      src/PicView.Avalonia/CustomControls/DraggableTabControl.cs

+ 4 - 1
src/PicView.Avalonia/CustomControls/DraggableTabControl.cs

@@ -410,7 +410,10 @@ public class DraggableTabControl : TabControl
                 CreateGhostWindow(_pressedTab);
                 break;
             case true when absDeltaY <= DetachThreshold:
-                if (TabDragContext.CurrentTarget == null || TabDragContext.CurrentTarget == this)
+                // Check if the pointer is within the horizontal bounds of the control
+                var isWithinBounds = _lastPointerPosition.X >= 0 && _lastPointerPosition.X <= Bounds.Width;
+
+                if (isWithinBounds && (TabDragContext.CurrentTarget == null || TabDragContext.CurrentTarget == this))
                 {
                     _isDetaching = false;
                     PseudoClasses.Set(PseudoDetaching, false);