11using System . Reactive . Disposables ;
2-
32using Avalonia ;
43using Avalonia . Controls ;
54using Avalonia . Controls . Presenters ;
87using Avalonia . Interactivity ;
98using Avalonia . LogicalTree ;
109using Avalonia . VisualTree ;
11-
1210using Beutl . Reactive ;
13-
1411using FluentAvalonia . Core ;
1512
1613#nullable enable
@@ -120,7 +117,7 @@ private void OnCloseClick(object? sender, RoutedEventArgs e)
120117
121118 private void OnDragAreaPointerExited ( object ? sender , PointerEventArgs e )
122119 {
123- _pressed = false ;
120+ // _pressed = false;
124121 }
125122
126123 private void OnDragAreaPointerReleased ( object ? sender , PointerReleasedEventArgs e )
@@ -132,30 +129,32 @@ private void OnDragAreaPointerMoved(object? sender, PointerEventArgs e)
132129 {
133130 if ( _dragArea == null || ! _pressed ) return ;
134131
135- PointerPoint pointer = e . GetCurrentPoint ( null ) ;
136- Point point = pointer . Position ;
137- Point delta = point - _point ;
138-
139132 if ( this . FindLogicalAncestorOfType < Popup > ( ) is { } popup )
140133 {
134+ PointerPoint pointer = e . GetCurrentPoint ( null ) ;
135+ Point point = pointer . Position ;
136+ Point delta = point - _point ;
137+
141138 popup . HorizontalOffset += delta . X ;
142139 popup . VerticalOffset += delta . Y ;
140+ if ( this . FindAncestorOfType < PopupRoot > ( ) == null )
141+ {
142+ _point = point ;
143+ }
143144 }
144145 }
145146
146147 private void OnDragAreaPointerPressed ( object ? sender , PointerPressedEventArgs e )
147148 {
148149 if ( _dragArea == null ) return ;
149150
151+ var root = this . FindAncestorOfType < PopupRoot > ( ) ;
150152 PointerPoint pointer = e . GetCurrentPoint ( null ) ;
151153 if ( pointer . Properties . IsLeftButtonPressed )
152154 {
153155 _pressed = true ;
154156 _point = pointer . Position ;
155- if ( this . FindAncestorOfType < PopupRoot > ( ) is { } root )
156- {
157- root . Activate ( ) ;
158- }
157+ root ? . Activate ( ) ;
159158 }
160159 }
161160}
0 commit comments