Home > Net >  Is there any way to implement long press gesture with SkiaSharp?
Is there any way to implement long press gesture with SkiaSharp?

Time:11-02

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.

  • Related