Disable feature that causes pressing "Tab" to cycle through available TextFields

When I press "Tab" on my keyboard, Unity automatically seems to cycle through all the GUILayout.TextField and set focus to them, allowing me to start typing. I do not want this and would like to get rid of the functionality. Is there any way to do this?

I even tried a hacky fix like this

if( Event.current.keyCode == KeyCode.Tab )
{
    Event.current.Use();
}

just before drawing my TextField, but it didn't help (and didn't feel right anyway).

Noting that [TextField eats keys][1], in what way did that not work? [1]: http://answers.unity3d.com/questions/149483/textfield-eats-all-keys-as-of-340.html

2 Answers

2

what if you somehow keep track of what field was previously selected and then if focus changes, then you force focus back on that field?

How about this for hack attempt number two:

if ( Event.current.keyCode == KeyCode.Tab ) {
    GUI.FocusControl(GUI.GetNameOfFocusedControl);
    Event.current.Use();
}

Just a thought... I've never played around with GUI focus.

If that doesn't work you could always keep track of the last focused control and go back to that when you detect a TAB.