Hello,
Welcome to our Microsoft Q&A platform!
If you judge single tap or double tap in SKTouchAction.Moved
tag, your finger cannot left your screen, it will not work for double tap.
So, you can hanle the single tap or double tap in SKTouchAction.Pressed:
like following code.
private static int clickCount;
private static object _sender;
// Dictionary<long, SKPoint> dragDictionary = new Dictionary<long, SKPoint>();
private void CanvasView_Touch(object sender, SKTouchEventArgs e)
{
// throw new System.NotImplementedException();
switch (e.ActionType)
{
case SKTouchAction.Pressed:
if (clickCount < 1)
{
TimeSpan tt = new TimeSpan(0, 0, 0, 0, 250);
_sender = sender;
Device.StartTimer(tt, ClickHandle);
}
clickCount++;
break;
case SKTouchAction.Entered:
// Console.WriteLine("======================Entered================");
break;
case SKTouchAction.Moved:
// Console.WriteLine("======================Moved================");
//if (dragDictionary.Keys.Count > 1)
//{
// dragDictionary[e.Id] = e.Location;
// SKPoint? p1 = null;
// SKPoint? p2 = null;
// foreach (long key in dragDictionary.Keys)
// {
// if (p1 == null)
// {
// p1 = dragDictionary[key];
// }
// else if (p2 == null)
// {
// p2 = dragDictionary[key];
// }
// }
// //MultiTouch handle
// Console.WriteLine("======================DOUBLE TAP================");
//}
//else
//{
// //SingleTouch handle
// Console.WriteLine("======================SINGLE TAP================");
//}
break;
case SKTouchAction.Released:
// dragDictionary.Remove(e.Id);
break;
case SKTouchAction.Exited:
break;
}
// we have handled these events
e.Handled = true;
((SKCanvasView)sender).InvalidateSurface();
}
private bool ClickHandle()
{
if (clickCount > 1)
{
DisplayAlert("info", "DOUBLE TAP","Ok");
}
else
{
DisplayAlert("info", "single TAP", "Ok");
}
clickCount = 0;
_sender = null;
return false;
}
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.