Monday, March 26, 2018

Detect whether touch was Apple Pencil or finger in webview (react native)

Leave a Comment

In safari mobile, touches can be classified as Apple Pencil vs other (finger/ mouse) using:

event.touches[0].touchType === 'stylus' //pencil event.touches[0].touchType !== 'stylus' //other 

However all events received in a react native webview (both for Apple Pencil and using a finger) are receiving:

touchType === 'direct' //inside webview, both pencil and other 

How can I detect a touch with the Apple Pencil inside a webview?

Apparently event.touches[0] > 0 is another possibility but this is also being set to 0 for both types in webview.

(Not sure if this is an issue with react native or a built-in limitation of webviews).

Related:

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment