Skiasharp - Detected Selected Touch Point

Yusuf 681 Reputation points
2021-01-31T12:59:31.557+00:00

Hi
In this example there are four touch points

TouchPoints[0], touchPoints1, touchPoints[2] and touchPoints[3]

https://github.com/xamarin/xamarin-forms-samples/blob/master/SkiaSharpForms/Demos/Demos/SkiaSharpFormsDemos/Curves/BezierCurvePage.xaml.cs

How can I detected which touch point is being moved

Thank you in advance.

@Matthew Leibowitz

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
0 comments No comments
{count} votes

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-02-02T02:46:31.857+00:00

    Hello,

    Welcome to Microsoft Q&A!

    • Define a new public variable ID inside TouchPoint class .
    • Assign the value when initializing in BezierCurvePage.cs . for (int i = 0; i < 4; i++)
      {
      TouchPoint touchPoint = new TouchPoint
      {
      Center = new SKPoint(100 + 200 * (i % 2),100 + 200 * i),
      ID = i
      };
      touchPoints[i] = touchPoint
      }
    • Detect which point is dragged in method ProcessTouchEvent in TouchPoint class case TouchActionType.Moved:
      if (isBeingDragged && touchId == id)
      {
      Console.WriteLine("ID=" + ID); //here you can get which is dragged
              Center += location - previousPoint;  
              previousPoint = location;  
              centerMoved = true;  
         }  
      
      break;

    Thank you.


    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.


1 additional answer

Sort by: Most helpful
  1. mc 3,641 Reputation points
    2021-02-01T00:20:00.43+00:00

    there is a toucheffect in xaml file.
    in OnTouchEffectAction you can get the points which is moved.

    to overview the OnTouchEffectAction you can download the project and press F12 to check the function.