How would I get the coordinates of my touch event. So I tap anywhere within the display and I can retrieve the X, Y positioning of where it happened.
TouchableOpacity can be used to provide feedback by reducing the opacity of the button, allowing the background to be seen through while the user is pressing down. If you need to handle a tap gesture but you don't want any feedback to be displayed, use TouchableWithoutFeedback.
Tapping any button will fire the respective onPress callback and dismiss the alert. By default, the only button will be an 'OK' button. This is an API that works both on Android and iOS and can show static alerts.
Definition of on press : being printed The book is on press now and due out soon.
You will need to wrap your view object with TouchableOpacity or one of the other Touchable components. With TouchableOpacity you have the onPress prop that is passed a press event. From this press event you have access to the x,y coordinates of the press.
pseudo code would look like this:
render() { .... <TouchableOpacity onPress={(evt) => this.handlePress(evt) } .... > <View></View> </TouchableOpacity> } handlePress(evt){ console.log(`x coord = ${evt.nativeEvent.locationX}`); }
Put it on your view tag and you can get all coordinates
<View onTouchStart={(e) => {console.log('touchMove',e.nativeEvent)}} />
For example
<View onTouchStart={(e) => {console.log('touchMove',e.nativeEvent)}} />
However this event only work with tag. so you can set view according to your requirement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With