Select all text in a GUI.TextField?

Hi, I would like my menu to select all text in a TextField when the user clicks on it.

I have found this related question so far, but the solution suggested there (having something else selected first by GUI.FocusControl) doesn’t achieve that result.

Is there any method to select the whole text? Anything?

Try using TextEditor class:

idString = GUI.TextField(new Rect (0, 0, 100, 20), idString);
textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

Then textEditor gives you cursor position and similar things. Maybe it has selection too. It’s undocumented class, IIRC, so use with caution.