Merge pull request #716 from charlenni/master
This commit is contained in:
Коммит
e87b3a4d6a
|
@ -6,11 +6,16 @@ namespace SkiaSharp.Views.Forms
|
|||
public class SKTouchEventArgs : EventArgs
|
||||
{
|
||||
public SKTouchEventArgs(long id, SKTouchAction type, SKPoint location, bool inContact)
|
||||
: this(id, type, SKMouseButton.Left, SKTouchDeviceType.Touch, location, inContact)
|
||||
: this(id, type, SKMouseButton.Left, SKTouchDeviceType.Touch, location, inContact, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton, SKTouchDeviceType deviceType, SKPoint location, bool inContact)
|
||||
: this(id, type, mouseButton, deviceType, location, inContact, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton, SKTouchDeviceType deviceType, SKPoint location, bool inContact, int wheelDelta)
|
||||
{
|
||||
Id = id;
|
||||
ActionType = type;
|
||||
|
@ -18,6 +23,7 @@ namespace SkiaSharp.Views.Forms
|
|||
MouseButton = mouseButton;
|
||||
Location = location;
|
||||
InContact = inContact;
|
||||
WheelDelta = wheelDelta;
|
||||
}
|
||||
|
||||
public bool Handled { get; set; }
|
||||
|
@ -34,9 +40,11 @@ namespace SkiaSharp.Views.Forms
|
|||
|
||||
public bool InContact { get; private set; }
|
||||
|
||||
public int WheelDelta { get; private set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{{ActionType={ActionType}, DeviceType={DeviceType}, Handled={Handled}, Id={Id}, InContact={InContact}, Location={Location}, MouseButton={MouseButton}}}";
|
||||
return $"{{ActionType={ActionType}, DeviceType={DeviceType}, Handled={Handled}, Id={Id}, InContact={InContact}, Location={Location}, MouseButton={MouseButton}, WheelDelta={WheelDelta}}}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +56,7 @@ namespace SkiaSharp.Views.Forms
|
|||
Released,
|
||||
Cancelled,
|
||||
Exited,
|
||||
WheelChanged,
|
||||
}
|
||||
|
||||
public enum SKTouchDeviceType
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace SkiaSharp.Views.Forms
|
|||
view.PointerMoved -= OnPointerMoved;
|
||||
view.PointerReleased -= OnPointerReleased;
|
||||
view.PointerCanceled -= OnPointerCancelled;
|
||||
view.PointerWheelChanged -= OnPointerWheelChanged;
|
||||
if (enableTouchEvents)
|
||||
{
|
||||
view.PointerEntered += OnPointerEntered;
|
||||
|
@ -35,6 +36,7 @@ namespace SkiaSharp.Views.Forms
|
|||
view.PointerMoved += OnPointerMoved;
|
||||
view.PointerReleased += OnPointerReleased;
|
||||
view.PointerCanceled += OnPointerCancelled;
|
||||
view.PointerWheelChanged += OnPointerWheelChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +91,11 @@ namespace SkiaSharp.Views.Forms
|
|||
args.Handled = CommonHandler(sender, SKTouchAction.Cancelled, args);
|
||||
}
|
||||
|
||||
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs args)
|
||||
{
|
||||
args.Handled = CommonHandler(sender, SKTouchAction.WheelChanged, args);
|
||||
}
|
||||
|
||||
private bool CommonHandler(object sender, SKTouchAction touchActionType, PointerRoutedEventArgs evt)
|
||||
{
|
||||
if (onTouchAction == null || scalePixels == null)
|
||||
|
@ -105,7 +112,9 @@ namespace SkiaSharp.Views.Forms
|
|||
var mouse = GetMouseButton(pointerPoint);
|
||||
var device = GetTouchDevice(evt);
|
||||
|
||||
var args = new SKTouchEventArgs(id, touchActionType, mouse, device, skPoint, evt.Pointer.IsInContact);
|
||||
var wheelDelta = pointerPoint?.Properties?.MouseWheelDelta ?? 0;
|
||||
|
||||
var args = new SKTouchEventArgs(id, touchActionType, mouse, device, skPoint, evt.Pointer.IsInContact, wheelDelta);
|
||||
onTouchAction(args);
|
||||
return args.Handled;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче