|
|
|
@ -11,7 +11,7 @@ namespace Avalonia.Input |
|
|
|
private readonly IVisual? _rootVisual; |
|
|
|
private readonly Point _rootVisualPosition; |
|
|
|
private readonly PointerPointProperties _properties; |
|
|
|
private Lazy<IReadOnlyList<RawPointerPoint>?>? _previousPoints; |
|
|
|
private readonly Lazy<IReadOnlyList<RawPointerPoint>?>? _previousPoints; |
|
|
|
|
|
|
|
public PointerEventArgs(RoutedEvent routedEvent, |
|
|
|
IInteractive? source, |
|
|
|
@ -43,29 +43,6 @@ namespace Avalonia.Input |
|
|
|
{ |
|
|
|
_previousPoints = previousPoints; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class EmulatedDevice : IPointerDevice |
|
|
|
{ |
|
|
|
private readonly PointerEventArgs _ev; |
|
|
|
|
|
|
|
public EmulatedDevice(PointerEventArgs ev) |
|
|
|
{ |
|
|
|
_ev = ev; |
|
|
|
} |
|
|
|
|
|
|
|
public void ProcessRawEvent(RawInputEventArgs ev) => throw new NotSupportedException(); |
|
|
|
|
|
|
|
public IInputElement? Captured => _ev.Pointer.Captured; |
|
|
|
public void Capture(IInputElement? control) |
|
|
|
{ |
|
|
|
_ev.Pointer.Capture(control); |
|
|
|
} |
|
|
|
|
|
|
|
public Point GetPosition(IVisual relativeTo) => _ev.GetPosition(relativeTo); |
|
|
|
|
|
|
|
public IPointer? TryGetPointer(RawPointerEventArgs ev) => _ev.Pointer; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets specific pointer generated by input device.
|
|
|
|
@ -77,28 +54,6 @@ namespace Avalonia.Input |
|
|
|
/// </summary>
|
|
|
|
public ulong Timestamp { get; } |
|
|
|
|
|
|
|
private IPointerDevice? _device; |
|
|
|
|
|
|
|
[Obsolete("Use Pointer to get pointer-specific information")] |
|
|
|
public IPointerDevice Device => _device ?? (_device = new EmulatedDevice(this)); |
|
|
|
|
|
|
|
[Obsolete("Use KeyModifiers and PointerPointProperties")] |
|
|
|
public InputModifiers InputModifiers |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
var mods = (InputModifiers)KeyModifiers; |
|
|
|
if (_properties.IsLeftButtonPressed) |
|
|
|
mods |= InputModifiers.LeftMouseButton; |
|
|
|
if (_properties.IsMiddleButtonPressed) |
|
|
|
mods |= InputModifiers.MiddleMouseButton; |
|
|
|
if (_properties.IsRightButtonPressed) |
|
|
|
mods |= InputModifiers.RightMouseButton; |
|
|
|
|
|
|
|
return mods; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a value that indicates which key modifiers were active at the time that the pointer event was initiated.
|
|
|
|
/// </summary>
|
|
|
|
@ -120,9 +75,6 @@ namespace Avalonia.Input |
|
|
|
/// <returns>The pointer position in the control's coordinates.</returns>
|
|
|
|
public Point GetPosition(IVisual? relativeTo) => GetPosition(_rootVisualPosition, relativeTo); |
|
|
|
|
|
|
|
[Obsolete("Use GetCurrentPoint")] |
|
|
|
public PointerPoint GetPointerPoint(IVisual? relativeTo) => GetCurrentPoint(relativeTo); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the PointerPoint associated with the current event
|
|
|
|
/// </summary>
|
|
|
|
@ -171,8 +123,6 @@ namespace Avalonia.Input |
|
|
|
|
|
|
|
public class PointerPressedEventArgs : PointerEventArgs |
|
|
|
{ |
|
|
|
private readonly int _clickCount; |
|
|
|
|
|
|
|
public PointerPressedEventArgs( |
|
|
|
IInteractive source, |
|
|
|
IPointer pointer, |
|
|
|
@ -184,13 +134,10 @@ namespace Avalonia.Input |
|
|
|
: base(InputElement.PointerPressedEvent, source, pointer, rootVisual, rootVisualPosition, |
|
|
|
timestamp, properties, modifiers) |
|
|
|
{ |
|
|
|
_clickCount = clickCount; |
|
|
|
ClickCount = clickCount; |
|
|
|
} |
|
|
|
|
|
|
|
public int ClickCount => _clickCount; |
|
|
|
|
|
|
|
[Obsolete("Use PointerPressedEventArgs.GetCurrentPoint(this).Properties")] |
|
|
|
public MouseButton MouseButton => Properties.PointerUpdateKind.GetMouseButton(); |
|
|
|
public int ClickCount { get; } |
|
|
|
} |
|
|
|
|
|
|
|
public class PointerReleasedEventArgs : PointerEventArgs |
|
|
|
@ -210,9 +157,6 @@ namespace Avalonia.Input |
|
|
|
/// Gets the mouse button that triggered the corresponding PointerPressed event
|
|
|
|
/// </summary>
|
|
|
|
public MouseButton InitialPressMouseButton { get; } |
|
|
|
|
|
|
|
[Obsolete("Use InitialPressMouseButton")] |
|
|
|
public MouseButton MouseButton => InitialPressMouseButton; |
|
|
|
} |
|
|
|
|
|
|
|
public class PointerCaptureLostEventArgs : RoutedEventArgs |
|
|
|
|