Skip to content

Commit

Permalink
Fixed drag and drop obsolete API usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jp2masa committed Jan 8, 2020
1 parent 9c3fd08 commit fcffbc3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Avalonia.Input/DragDropDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private Interactive GetTarget(IInputRoot root, Point local)
return null;
}

private DragDropEffects RaiseDragEvent(Interactive target, IInputRoot inputRoot, Point point, RoutedEvent<DragEventArgs> routedEvent, DragDropEffects operation, IDataObject data, InputModifiers modifiers)
private DragDropEffects RaiseDragEvent(Interactive target, IInputRoot inputRoot, Point point, RoutedEvent<DragEventArgs> routedEvent, DragDropEffects operation, IDataObject data, KeyModifiers modifiers)
{
if (target == null)
return DragDropEffects.None;
Expand All @@ -38,13 +38,13 @@ private DragDropEffects RaiseDragEvent(Interactive target, IInputRoot inputRoot,
return args.DragEffects;
}

private DragDropEffects DragEnter(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, InputModifiers modifiers)
private DragDropEffects DragEnter(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, KeyModifiers modifiers)
{
_lastTarget = GetTarget(inputRoot, point);
return RaiseDragEvent(_lastTarget, inputRoot, point, DragDrop.DragEnterEvent, effects, data, modifiers);
}

private DragDropEffects DragOver(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, InputModifiers modifiers)
private DragDropEffects DragOver(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, KeyModifiers modifiers)
{
var target = GetTarget(inputRoot, point);

Expand Down Expand Up @@ -77,7 +77,7 @@ private void DragLeave(IInputElement inputRoot)
}
}

private DragDropEffects Drop(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, InputModifiers modifiers)
private DragDropEffects Drop(IInputRoot inputRoot, Point point, IDataObject data, DragDropEffects effects, KeyModifiers modifiers)
{
try
{
Expand Down
23 changes: 19 additions & 4 deletions src/Avalonia.Input/DragEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ public class DragEventArgs : RoutedEventArgs

public IDataObject Data { get; private set; }

[Obsolete("Use KeyModifiers")]
public InputModifiers Modifiers { get; private set; }

public KeyModifiers KeyModifiers { get; private set; }

public Point GetPosition(IVisual relativeTo)
{
var point = new Point(0, 0);
Expand All @@ -32,13 +35,25 @@ public Point GetPosition(IVisual relativeTo)
return point;
}

[Obsolete("Use constructor taking KeyModifiers")]
public DragEventArgs(RoutedEvent<DragEventArgs> routedEvent, IDataObject data, Interactive target, Point targetLocation, InputModifiers modifiers)
: base(routedEvent)
{
this.Data = data;
this._target = target;
this._targetLocation = targetLocation;
this.Modifiers = modifiers;
Data = data;
_target = target;
_targetLocation = targetLocation;
Modifiers = modifiers;
KeyModifiers = (KeyModifiers)(((int)modifiers) & 0xF);
}

public DragEventArgs(RoutedEvent<DragEventArgs> routedEvent, IDataObject data, Interactive target, Point targetLocation, KeyModifiers keyModifiers)
: base(routedEvent)
{
Data = data;
_target = target;
_targetLocation = targetLocation;
Modifiers = (InputModifiers)keyModifiers;
KeyModifiers = keyModifiers;
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Input/Raw/RawDragEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class RawDragEvent : RawInputEventArgs
public IDataObject Data { get; }
public DragDropEffects Effects { get; set; }
public RawDragEventType Type { get; }
public InputModifiers Modifiers { get; }
public KeyModifiers Modifiers { get; }

public RawDragEvent(IDragDropDevice inputDevice, RawDragEventType type,
IInputRoot root, Point location, IDataObject data, DragDropEffects effects, RawInputModifiers modifiers)
Expand All @@ -16,7 +16,7 @@ public RawDragEvent(IDragDropDevice inputDevice, RawDragEventType type,
Location = location;
Data = data;
Effects = effects;
Modifiers = (InputModifiers)modifiers;
Modifiers = KeyModifiersUtils.ConvertToKey(modifiers);
}
}
}

0 comments on commit fcffbc3

Please sign in to comment.