x


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?

more ▼

asked Sep 18, 2012 at 04:30 PM

ignotuscaligo gravatar image

ignotuscaligo
20 25 24 26

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x6073
x322
x241
x101

asked: Sep 18, 2012 at 04:30 PM

Seen: 1915 times

Last Updated: Feb 25, 2013 at 08:40 PM