diff --git a/src/Avalonia.Input/DragDropDevice.cs b/src/Avalonia.Input/DragDropDevice.cs index 25d3b6887f9..bcd962bc318 100644 --- a/src/Avalonia.Input/DragDropDevice.cs +++ b/src/Avalonia.Input/DragDropDevice.cs @@ -19,7 +19,7 @@ private Interactive GetTarget(IInputRoot root, Point local) return null; } - private DragDropEffects RaiseDragEvent(Interactive target, IInputRoot inputRoot, Point point, RoutedEvent routedEvent, DragDropEffects operation, IDataObject data, InputModifiers modifiers) + private DragDropEffects RaiseDragEvent(Interactive target, IInputRoot inputRoot, Point point, RoutedEvent routedEvent, DragDropEffects operation, IDataObject data, KeyModifiers modifiers) { if (target == null) return DragDropEffects.None; @@ -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); @@ -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 { @@ -100,16 +100,16 @@ private void ProcessRawEvent(RawDragEvent e) switch (e.Type) { case RawDragEventType.DragEnter: - e.Effects = DragEnter(e.Root, e.Location, e.Data, e.Effects, e.Modifiers); + e.Effects = DragEnter(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); break; case RawDragEventType.DragOver: - e.Effects = DragOver(e.Root, e.Location, e.Data, e.Effects, e.Modifiers); + e.Effects = DragOver(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); break; case RawDragEventType.DragLeave: DragLeave(e.Root); break; case RawDragEventType.Drop: - e.Effects = Drop(e.Root, e.Location, e.Data, e.Effects, e.Modifiers); + e.Effects = Drop(e.Root, e.Location, e.Data, e.Effects, e.KeyModifiers); break; } } diff --git a/src/Avalonia.Input/DragEventArgs.cs b/src/Avalonia.Input/DragEventArgs.cs index dc0b76b2252..08e9eb7d33b 100644 --- a/src/Avalonia.Input/DragEventArgs.cs +++ b/src/Avalonia.Input/DragEventArgs.cs @@ -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); @@ -32,13 +35,25 @@ public Point GetPosition(IVisual relativeTo) return point; } + [Obsolete("Use constructor taking KeyModifiers")] public DragEventArgs(RoutedEvent 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 routedEvent, IDataObject data, Interactive target, Point targetLocation, KeyModifiers keyModifiers) + : base(routedEvent) + { + Data = data; + _target = target; + _targetLocation = targetLocation; + Modifiers = (InputModifiers)keyModifiers; + KeyModifiers = keyModifiers; } } diff --git a/src/Avalonia.Input/Raw/RawDragEvent.cs b/src/Avalonia.Input/Raw/RawDragEvent.cs index 5722e175931..4193cdafc56 100644 --- a/src/Avalonia.Input/Raw/RawDragEvent.cs +++ b/src/Avalonia.Input/Raw/RawDragEvent.cs @@ -1,4 +1,6 @@ -namespace Avalonia.Input.Raw +using System; + +namespace Avalonia.Input.Raw { public class RawDragEvent : RawInputEventArgs { @@ -6,7 +8,9 @@ public class RawDragEvent : RawInputEventArgs public IDataObject Data { get; } public DragDropEffects Effects { get; set; } public RawDragEventType Type { get; } + [Obsolete("Use KeyModifiers")] public InputModifiers Modifiers { get; } + public KeyModifiers KeyModifiers { get; } public RawDragEvent(IDragDropDevice inputDevice, RawDragEventType type, IInputRoot root, Point location, IDataObject data, DragDropEffects effects, RawInputModifiers modifiers) @@ -17,6 +21,7 @@ public RawDragEvent(IDragDropDevice inputDevice, RawDragEventType type, Data = data; Effects = effects; Modifiers = (InputModifiers)modifiers; + KeyModifiers = KeyModifiersUtils.ConvertToKey(modifiers); } } }