1
\$\begingroup\$

i am trying to create a tag system for a journal i'm making and that requires being able to select specific parts from either an input field or a text element with the finger (drag and select) and then save that selection into a list.

The issue is i don't know how to do it! i did some google research in terms of "saving selected text from input fields" and similar searches but i couldn't find something to help me out.

The flow should be : user types something like "hello world" , then he drags his finger on the screen highlighting the word "World" and once highlighted it is saved into an empty string which then i can add to the list i want.

Can i get some help or recommendations on what to read to make it happen? Thank you!

\$\endgroup\$
3
  • \$\begingroup\$ The Text Mesh Pro documentation shows API methods to get the character index where the selection starts and the length of the selection, if I recall correctly, and an event fired when the selection is completed — have you tried using these? \$\endgroup\$
    – DMGregory
    Aug 21, 2021 at 14:41
  • \$\begingroup\$ no as a matter of fact i didnt know that! i did take a look at it but i dont know how to use it, its a class right? do i need other events? \$\endgroup\$
    – stratos la
    Aug 22, 2021 at 17:55
  • \$\begingroup\$ @stratosla have you solved the issue? \$\endgroup\$
    – IARI
    Sep 19, 2021 at 19:27

1 Answer 1

0
\$\begingroup\$

I have not worked with mobile yet. But you can find the selection something like:

int start = your_inputfield.selectionAnchorPosition;

int end~ = your_inputfield.selectionStringFocusPosition;

From there you would want a context popup or something with a button to save selection.

tmp_inputfield.selectionAnchorPosition {Get; Set;}

tmp_inputfield.selectionStringFocusPosition {Get; Set;}

The two properties of tmp_inputfield can be treated like variables if you are unfamiliar.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .