Apple Pencil

I’m seeing odd behaviour with the Apple Pencil in some of my apps. The touch events do not seem to behave in the same way as when using a simple stylus or finger. Has any one else had any issues getting Corona and the Apple Pencil to work together?

As I don’t have an iPad capable of using an Apple Pencil, I cannot reproduce these issues: my app works fine unless an Apple Pencil is used.

Can you describe the behaviors?  The new apple pencil has increased pressure sensitivity and a tilt-shading function that might explain some of the unexpected results.

From what I’ve seen remotely, the app gets stuck in strange places. For instance I have a button on the screen; if you tap the button after 1 second a dot appears. If you release prematurely the timer restarts and you get a warning.

The footage I saw showed the user tapping the apple pencil on the button, the button highlighted, and the user got a warning that they had prematurely released the button. As this is only happening with the Apple Pencil, I am wondering whether there are new touch even types being generated or whether the coordinate system is different.

Without being able to reproduce these issues I either need to buy/borrow a new iPad and Apple pencil, or write a short app which just spits out the events it’s receiving. Of course, it could be the Apple Pencil is dud.

Hence this post, I was curious as to whether others have had odd bugs which only occur with Apple Pencils, or whether there is something wrong with my touch handler and purely by chance it so far has only shown up when using an Apple Pencil.

Here is a simplified version of my touch handler (I’ve tried to strip everything spurious out to make the logic easier to follow):

function startMoveTimer() if moveTimer then return end local reactionTime local screenTrace = function(event) if event.phase == "began" then warning.isVisible = true warning.text = warnings.letGo end -- log touch data to CSV end Runtime:addEventListener("touch", screenTrace) moveTimer = timer.performWithDelay(1000,function() Runtime:removeEventListener("touch", screenTrace) moveTimer = nil -- log data to CSV startButton.isVisible = true warning.isVisible = false startButton.setHighlighted(false) if taskComplete() then startButton:removeEventListener("touch", task) end end) end local touchStart task = function(event) if event.phase == "began" then touchID = event.id touchStart = event.time display.getCurrentStage():setFocus(startButton,event.id) warning.isVisible = false startButton.setHighlighted(true) if touchTimer then timer.cancel(touchTimer) end touchTimer = timer.performWithDelay(1000, function(event) touchTimer = nil startButton.isHitTestable = false startButton.isVisible = false primedForInput = true end) end if event.id ~= touchID then return end if event.phase == "moved" then local dx = event.x - event.xStart local dy = event.y - event.yStart if dx \* dx + dy \* dy \> moveThreshold \* moveThreshold and event.time - touchStart\>= moveTimeThreshold then if touchTimer then warning.isVisible = true warning.text = warnings.tooEarlyMove startButton.isVisible = true timer.pause(touchTimer) elseif primedForInput then primedForInput = false startMoveTimer() end end end if event.phase == "moved" and self.outOfBounds(event) or event.phase == "ended" then startButton.setHighlighted(false) if touchTimer then warning.isVisible = true warning.text = warnings.tooEarlyOutOff startButton.isVisible = true timer.pause(touchTimer) elseif event.phase == "ended" then if primedForInput then primedForInput = false startMoveTimer() end end if event.phase == "ended" then display.getCurrentStage():setFocus(nil) end end end startButton:addEventListener("touch", task)