iOS 1 or 2 Touches?

I have a canvas that reacts to pointer down, pointer move etc by drawing.
For obvious reasons, people also expect to be able to pinch zoom.

I thought I had a reasonable handle on this by noticing how many points I have in the pointerdown, and only doing something zoomy about it if I STILL have two in the move event.

PointerDown:

If pointerinfo.ubound > 0 Then
  //multi touch .. get out
  Exit Sub
End If

PointerDrag:

If pointerinfo.ubound > 0 Then
  //multi touch .. record here, change zoom? and get out
  var thisdistance as double
  static lastx,lasty as integer
  
  thisdistance =  abs(pointerinfo(0).position.DistanceTo( pointerinfo(1).position))
  //etc
end if

But what I am hearing from people using an Apple Pencil, is that they get stray events - either odd touches from their fingers, or odd zooms when it detects a mix of Pencil and (presumably) fingers.

Is there a way to detect whether a pointer event is one from a pencil ONLY and ignore ‘fat fingers’?

Pinches are usually not done with individual touches but with Gesture Recognizers. That way you don’t have to figure out all of the math to get it right.

I’m sure that iOSKit or Jeremie’s extensions cover this.

Pinch is working with this code.
TBH, I included IOSKit in an older project and have had no end of trouble with it.
I really don’t want to include it now, as I am (probably stupidly) trying to avoid too much rework/iOS dependance , just in case I can ever use Xojo to build for Android.

I suspect for my fat finger issue, I need a user setting to say
‘Im using a Pencil, so ignore any touches with a diameter over (some size to be determined by guesswork) unless its a multi-touch’

I suspect if you use Jeremie’s extensions you’ll have less trouble as he uses that stuff for his own active development.

I use iOSKit for gesture recognizers and I use it in all my projects. It is in my iOS project template.

Gesture recognizers aren’t part of iOSdesignExtensions.

iOSKit aside, I was looking for advice on pencil versus ‘stray fingers’

In API1, the canvas Pointer events used iOSEventInfo class where the handle was exposed. Allowing for more information to be retrieved, using declares.

Unfortunately with API2, iOSEventInfo is replaced with PointerEvent which has no exposed handle.

<https://xojo.com/issue/64316>