Skip to content

Commit 27c6ace

Browse files
committed
make lastPointerPosition trackable at the drag event
make _lastKnownPosition trackable at dragging adding additional comments regarding fix delete unnecessary lines
1 parent 98a388d commit 27c6ace

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Avalonia.Base/Input/PointerOverPreProcessor.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,21 @@ public void OnError(Exception error)
2929

3030
public void OnNext(RawInputEventArgs value)
3131
{
32-
if (value is RawPointerEventArgs args
33-
&& args.Root == _inputRoot
34-
&& value.Device is IPointerDevice pointerDevice)
32+
if (value is RawDragEvent dragArgs)
33+
{
34+
// When a platform drag operation is in progress, the application does not receive
35+
// pointer move events until after the drop event. This is a problem because if a
36+
// popup is shown at the pointer position in the drop event, it will be shown at
37+
// the position at which the drag was initiated, not the position at which the drop
38+
// occurred.
39+
//
40+
// Solve this by updating the last known pointer position when a drag event occurs.
41+
_lastKnownPosition = ((Visual)_inputRoot).PointToScreen(dragArgs.Location);
42+
}
43+
44+
else if (value is RawPointerEventArgs args
45+
&& args.Root == _inputRoot
46+
&& value.Device is IPointerDevice pointerDevice)
3547
{
3648
if (pointerDevice != _lastActivePointerDevice)
3749
{

0 commit comments

Comments
 (0)