terrylinla / react-native-sketch-canvas

A React Native component for drawing by touching on both iOS and Android.
MIT License
691 stars 450 forks source link

Is it possible to detect if the touch is from apple pencil or hand? #235

Open PankajPunia opened 1 year ago

PankajPunia commented 1 year ago

I'm using this library in an iPad app for making notes. When user is using an apple pencil to draw on canvas, i want to draw only with pencil touch not with any other gesture , for example , sometimes, i see unexpected lines and dots because of the palm resting on iPad screen.

Is there a way to handle this case? Is it possible to detect if the touch is from pencil or palm?

@terrylinla @diego-caceres @jeanregisser @artdevgame @toblerpwn

PankajPunia commented 1 year ago

I kind of resolved it using another approach that helps in avoiding multiple touches. I updated the code in SketchCanvas.js file as follows :

Replaced if (!this.props.touchEnabled) return with if (!this.props.touchEnabled || gestureState.numberActiveTouches > 1) return in onPanResponderGrant, onPanResponderMove and onPanResponderRelease functions