Browse Source

Use DragEventArgs for DragLeave event.

This follows the WPF/UWP API and allows pointer information to be retrieved.
pull/9243/head
Steven Kirk 3 years ago
parent
commit
89faa52240
  1. 2
      src/Avalonia.Base/Input/DragDrop.cs
  2. 8
      src/Avalonia.Base/Input/DragDropDevice.cs

2
src/Avalonia.Base/Input/DragDrop.cs

@ -13,7 +13,7 @@ namespace Avalonia.Input
/// <summary> /// <summary>
/// Event which is raised, when a drag-and-drop operation leaves the element. /// Event which is raised, when a drag-and-drop operation leaves the element.
/// </summary> /// </summary>
public static readonly RoutedEvent<RoutedEventArgs> DragLeaveEvent = RoutedEvent.Register<RoutedEventArgs>("DragLeave", RoutingStrategies.Bubble, typeof(DragDrop)); public static readonly RoutedEvent<DragEventArgs> DragLeaveEvent = RoutedEvent.Register<DragEventArgs>("DragLeave", RoutingStrategies.Bubble, typeof(DragDrop));
/// <summary> /// <summary>
/// Event which is raised, when a drag-and-drop operation is updated while over the element. /// Event which is raised, when a drag-and-drop operation is updated while over the element.
/// </summary> /// </summary>

8
src/Avalonia.Base/Input/DragDropDevice.cs

@ -54,7 +54,7 @@ namespace Avalonia.Input
try try
{ {
if (_lastTarget != null) if (_lastTarget != null)
_lastTarget.RaiseEvent(new RoutedEventArgs(DragDrop.DragLeaveEvent)); RaiseDragEvent(_lastTarget, inputRoot, point, DragDrop.DragLeaveEvent, effects, data, modifiers);
return RaiseDragEvent(target, inputRoot, point, DragDrop.DragEnterEvent, effects, data, modifiers); return RaiseDragEvent(target, inputRoot, point, DragDrop.DragEnterEvent, effects, data, modifiers);
} }
finally finally
@ -63,13 +63,13 @@ namespace Avalonia.Input
} }
} }
private void DragLeave(IInputElement inputRoot) private void DragLeave(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, KeyModifiers modifiers)
{ {
if (_lastTarget == null) if (_lastTarget == null)
return; return;
try try
{ {
_lastTarget.RaiseEvent(new RoutedEventArgs(DragDrop.DragLeaveEvent)); RaiseDragEvent(_lastTarget, inputRoot, point, DragDrop.DragLeaveEvent, effects, data, modifiers);
} }
finally finally
{ {
@ -106,7 +106,7 @@ namespace Avalonia.Input
e.Effects = DragOver(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); e.Effects = DragOver(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers);
break; break;
case RawDragEventType.DragLeave: case RawDragEventType.DragLeave:
DragLeave(e.Root); DragLeave(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers);
break; break;
case RawDragEventType.Drop: case RawDragEventType.Drop:
e.Effects = Drop(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); e.Effects = Drop(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers);

Loading…
Cancel
Save