How to highlight text in react native pdftron programmatically

Product:react native

Product Version:9.408051

Please give a brief summary of your issue:
(Think of this as an email subject)

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi there,
Could you tell us a bit more about what you would like to do? It looks like you may have missed filling out the required information in your message.

after I override copy in longpressmenu like this

overrideLongPressMenuBehavior={[Config.LongPressMenu.copy]}
          onLongPressMenuPress={({longPressMenu, longPressText}) => {
            if (longPressMenu === Config.LongPressMenu.copy) {
              this._viewer.current
                .getSelectionPageRange()
                .then(range => {
                  const pages = this.getPages(range.begin, range.end);
                  return Promise.all(
                    pages.map(page => this._viewer.current.getSelection(page)),
                  );
                })
                .then(texts => {
                  this.setState({selectedtext: longPressText});
                  console.log(this.state.selectedtext);
                  console.log(JSON.stringify(texts[0], null, 4));
                   //write a function to highlight the selected text
                });
            }
          }}

from this i get the selected text pageNumber and qouds .
after this i should be able to highlight the selected text
thank you

As mentioned in your original post (https://community.pdftron.com/t/how-do-i-highlight-text-after-overriding-longmenupress-copy-clicked-and-getting-content-and-coordinates-of-the-copy-on-react-native/6789/1), you can accomplish what you want without any changes, by doing the following:

  • Long-press over some text on the page to select it
  • In the popup menu that appears, tap on the “Highlight” menu option (you may need to first tap the “>” button to see the “Highlight” menu option)

There should not be any programmatic changes required.

the requirement i have is
after i click to copy on longpressmenu it should select the text and also highlight the text .
how can I combine the two steps in one
thank you

From the description of your requirement, it sounds like the previous suggestion would work for you:

Could you please try this out to see if it works for your use case? The text will be selected and highlighted.