How to touch and hold to select text in React Native

I am new to Android and am trying to implement a rich editor using the React Native text component. However, when I touch the text and save for a moment, the text was not selected, and the top panel with the selection actions did not appear, like what behaves in web browsing or other applications. What am I missing or do I need to implement this function myself? If you could indicate the direction?

+7
source share
2 answers

If you want to click and hold text using the Text component, this feature does not currently exist in React Native for iOS. You probably want to add https://react-native.canny.io/feature-requests/p/support-selecting-text-within-text-elements-for-copypaste-etc to offer Facebook add support for this.

However, I introduced support for Android starting with React 0.30. But React iOS draws characters directly on the screen (and does not use its own UITextView, which supports the selected property), so it is not supported there and probably will not be for a long time.

RN 0.39 adds support for copying the entire text field, but does not yet include support for selecting a subset of the text field to copy.

+17
source

use onPress = {this.onPressTitle ()} inside the text

and declare

onPressTitle:function(){ /* Your Actions on OnPress */ } 
-5
source

Source: https://habr.com/ru/post/1236020/


All Articles