I have my touchable highlight with an onPress and an onLongPress. They both work as expected the problem is I want to reduce the duration the user has to hold the button before long press activates. Is there a way reduce how long the user has to hold the button for longpress?. Maybe some kind of overide?
<TouchableHighlight style={styles.square} onPress={this._onPressButton.bind(this,item)} onLongPress={this._onLongPressButton.bind(this,item)}>
<View style={styles.button}>
</View>
</TouchableHighlight>
Thanks in advance
There is a prop that you can pass to TouchableHighlight
1 called delayLongPress
. You can read about it here.
Basically what it allows you to do is set, in milliseconds, how long until onLongPress
is called.
From the documentation:
Delay in ms, from onPressIn, before onLongPress is called.
In the example below the duration has been set to 500ms.
<TouchableHighlight
style={styles.square}
onPress={this._onPressButton.bind(this, item)}
onLongPress={this._onLongPressButton.bind(this, item)}
delayLongPress={500}
>
<View style={styles.button}>
</View>
</TouchableHighlight>
1 Note that all Touchables
have the props from TouchableWithoutFeedback
. You can see the props for TouchableHightlight
here
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