Repository navigation
Adding touch events - #309
Conversation
- switch between gestures and touch events - improved performance as we don't need to listen always
|
All the views will get the There is a property,
Setting this property to This property is used to control the platforms:
Android:
iOS:
macOS:
UWP:
|
|
Any considerations for multitouch? I personally feel like having an event with a single touch point is pretty great for nearly all situations, so the implementation here makes that nice and clean. If I wanted to do any kinds of pinch style event, I suppose you could switch to a pinch gesture. For what it is worth, pinch and rotate are the two primary use cases that I can think of for multitouch. |
|
Multitouch is supported fully. The I have been testing with a sample like this, which i have gotten at least 10 pointers (I ran out of fingers): private readonly Dictionary<long, SKPoint> points = new Dictionary<long, SKPoint>();
private void OnTouching(object sender, SKTouchEventArgs e)
{
switch (e.ActionType)
{
case SKTouchAction.Entered:
case SKTouchAction.Pressed:
case SKTouchAction.Moved:
points[e.Id] = e.Location;
break;
case SKTouchAction.Released:
case SKTouchAction.Cancelled:
case SKTouchAction.Exited:
points.Remove(e.Id);
break;
}
((SKCanvasView)sender).InvalidateSurface();
} |
|
Just as an aside to this - I am currently using SkiaSharp in a Xamarin Forms project (works great!) and using these features on Android (not tested iOS yet) - and I have a canvas view with Pan and Pinch Xamarin forms gestures attached to it, and the SkiaSharp touch events enabled on it too, and they all work really nicely together. I can pan and pinch, and tap to get the location/point that I need. NB - also the iOS bug mentioned above has been fixed in Xamarin forms 2.3.6-pre1 and onwards. |
|
@darylwatts You said all three (pinch, pan and touch) work together nicely. However when I try to pinch or pan, my code always gets to the touch eventhandler of the SKCanvasView first, and after that it gets to the pinch/pan code. Because of this, pinching or panning isn't as smooth as it should be. It's laggy, and sometimes it just won't work. |
Uh oh!
There was an error while loading. Please reload this page.