在 Safari 移动端,可以使用以下方式将触摸分类为 Apple Pencil 与其他(手指/鼠标):
event.touches[0].touchType === 'stylus' //pencil
event.touches[0].touchType !== 'stylus' //other
然而,使用React Native Webview接收的所有事件(无论是使用Apple Pencil还是手指)都会被接收:
touchType === 'direct' //inside webview, both pencil and other
如何在Webview中检测使用Apple Pencil的触摸事件?
显然,event.touches[0] > 0
也是一种可能性,但在Webview中这对于两种类型都被设置为0
。
(不确定这是否是React Native的问题还是Webview的内置限制)。
相关链接: