So I have something like this:
//more GUILayout functions above...
enteredText = GUILayout.TextField(enteredText);
//... 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?
Answer by fabr.IQ
Feb 25, 2013 at 08:40 PM
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
10 People are following this question.
How to make camera position relative to a specific target.
Help with GUILayout and tooltip(C#)
Why does old text in GUILayout not disappear?
EditorGUI, EditorGUILayout, GUI, GUILayout... pshhh... WHEN TO USE WHAT?!
Using Gamepad to access onGUI menus?