# How to tell which letter or vertex of a letter is at a certain screen position with a Unity UI Toolkit Label or TextElement?

I am using the Unity UI Toolkit and I would like to create my own TextField class (ie. input field, similar to the one I'm typing in now to write this message) with better functions using the Label class or some other base text class. I can figure out how to do everything I need to do except one thing.

Quite simply, I think the correct mechanism is to upon clicking part way through a label, split it into two strings. The string before the caret goes to TouchScreenKeyboard.text so it is editable (I am developing for mobile), and the string after gets held. The label gets updated from the combo of the two strings after each new character typed.

Upon finishing editing or repositioning the caret, the two temp strings are formally recombined into the label.

In order to insert a caret, move it along with inputted text, and be able to insert text part way through when a certain spot is clicked, I believe I need to be able to know what letter is clicked on at a given point or how to track the position of any given letter at any time.

This is what I do not know how to do. I can see a thorough discussion of how to track vertexes and boxes of text letters in the old Unity UI system here. However, I don't think that helps the UI Toolkit.

Is there some way to figure out where each vertex or bounding box is for each letter in a text label from the UI Toolkit? Any ideas on where to start?

Otherwise how might I do this? I can see the existing quite flawed TextField they ship with Unity is made from these elements:

In particular, the text is a TextElement which I looked and is a base class that is what Label comes from. I don't know if I should use TextElement as the base for my construction or Label then. Either way, they also must have had to have a way to identify which letter is clicked or they could not have created the TextField at all, so I presume there is some solution.

Any thoughts? Thanks.