iOS Pencil

Is someone using Pencil with iOS ?
an have sample code to show

I do.
It ‘appears’ just like a thin finger to my code.
Pointer(0) gives you the co-ordinates

When I want to distinguish between a finger and the pencil, I check the pointer size (which varies accordingly)

if pointerinfo(0).Size > 15 then UsingFinger = true

To avoid accidental touches

To do something different when the user presses harder, I use:

if pointerinfo(0).Pressure > 1.5 then

Otherwise… what do YOU want to do?

I need to get signature with a pencil on a canvas

Record arrays of points in the PointerDrag event of a canvas.
(Remember that people will lift the pencil between parts.)

depending upon what you want to use it for, you may want to record timings too.

This post may be of help:

the project is no more available

The method described is still valid.

When the pad is shown, initialise an array of points

when the pointer goes down, add the x,y point to the array.
When the pointer moves, if x and y are different, add a new point to the list
When the pointer is lifted, add a point to the array with ‘special’ co-ordinates such as -99999,-99999

if the pointer goes down , add a new point, keep adding points in this way until the user taps ‘I have finished signing’

AT any time, invaildate the canvas.

In the Canvas paint event, draw lines from point x to point x +1
Unless point x + 1 is the special one
If it is, start again from the next point

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.