- Home /
GUI.FocusControl() and TextFields - Prevent selection
So I have something like this:
//more GUILayout functions above...
GUI.SetNextControlName("textEntry");
enteredText = GUILayout.TextField(enteredText);
GUI.FocusControl();
//... and more GUILayout functions below
What I want is for the text field to always be selected (hence the immediate focus control). Above this there is a section with changing layouts, which causes the text field to become unselected. When GUI.FocusControl() is in there, it maintains control of the text field, but it always selects ALL of the text any time there is a change above. If I'm typing something when it does this, it immediately deletes everything in the field.
My main question is, how do I keep focus on the text field without selecting all the text every time the layout changes? Is there a better way to handle this?
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Why can't I get my tooltip to show only when there is a tooltip set? 2 Answers
GUI.Window error. InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. 0 Answers
TextField, Event.current, Input.GetKey, and GUI.FocusControl locking 1 Answer
know GUILayout current screen position 2 Answers