I am using Skiasharp on Xamarin Forms app. With SKTouchAction I was trying to capture the time duration of SKTouchAction.Pressed and SKTouchAction.Released and find if the gesture is Long pressed or not. But the issue is SKTouchAction.Released is not triggered on Android.
protected override void OnTouch(SKTouchEventArgs e)
{
switch (e.ActionType)
{
case SKTouchAction.Moved:
break;
case SKTouchAction.Pressed:
//save current time here
break;
case SKTouchAction.Released:
//Compare time here to check long press
break;
}
}
CodePudding user response:
There is a similar issue on the github. It seems you need to let the OS know that you wanted to continue receiving touch events. Such as:
protected override void OnTouch(SKTouchEventArgs e)
{
e.Handled = true;
switch (e.ActionType)
{
case SKTouchAction.Moved:
break;
case SKTouchAction.Pressed:
//save current time here
break;
case SKTouchAction.Released:
//Compare time here to check long press
break;
}
}
In addition, you can also refer to this case.