I’m writing some custom editor windows (if you haven’t noticed from my other threads ;)) and I’m having trouble with text fields.
Specifically, if I have a text field focused in a window, then change the contents of that window from an action in a different window, when I return focus back to the first window it is automatically forwarded to the text box I had focussed, and this seems to make it remember its old value instead of displaying the new one.
I’m actually wondering if this is a bug that’s been introduced in a recent version, as I’ve noticed it happening in built-in editor windows as well. (The animation import pipeline springs to mind.)
I’ve tried focusing a dummy control and also setting GUIUtility.keyboardControl = 0; but neither do the trick.
How do I stop focus from being automatically returned to a text box in the Editor?
Edit: My mistake, there was an error in my dummy control focus code, and now that works. Still, it’d be nice not to need eyesores like the following scattered across my GUI windows…
if (nerfFocus) {
GUIUtility.keyboardControl = 0;
nerfFocus = false;
}
… not to mention the additional code that you need elsewhere, depending on how you’re managing your windows, to handle setting nerfFocus to true when relevant.