- Home /
Select TextField when it gets focus (in custom editor)
I'm writing custom editor and I want TextField to behave like string array element in default inspector. So when I click on particular TextField, it's text get selected.
I've got a TextField created like this inside OnInspectorGUI() method:
GUILayout.TextField("sample text");
When I click this field in editor, the caret get takes it's position, and nothing else! Text doesn't get selected.
I want the TextField's text to be fully selected on click. How can I achieve that?
And similar question... How may I focus TextField element from script without selecting it's text?
I know how to focus on element:
GUI.SetNextControlName("TMP");
EditorGUI.FocusTextInControl("TMP");
But it selects the text inside. I want the caret to be at the end of string.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172330im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Programmatically focus textfield in Editor 0 Answers
Hierarchy not showing anything, getting KeyNotFoundException 1 Answer
How do I get Unity to ask Windows for focus? 0 Answers
How can I create a editor button that can not be selected 0 Answers
Way to graphically visualize a Vector2 or Vector3 in inspector? 2 Answers