Skip to content

Commit c4ae01d

Browse files
committed
DraggablePickerFlyoutのドラッグ操作を修正
1 parent d7f3404 commit c4ae01d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Beutl.Controls/PropertyEditors/DraggablePickerFlyoutPresenter.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reactive.Disposables;
2-
32
using Avalonia;
43
using Avalonia.Controls;
54
using Avalonia.Controls.Presenters;
@@ -8,9 +7,7 @@
87
using Avalonia.Interactivity;
98
using Avalonia.LogicalTree;
109
using Avalonia.VisualTree;
11-
1210
using Beutl.Reactive;
13-
1411
using 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

Comments
 (0)