- Home /
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, in what way did that not work?
Answer by BerggreenDK · Aug 15, 2011 at 10:34 AM
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?
Answer by jahroy · Oct 19, 2011 at 05:48 AM
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.
Your answer
Follow this Question
Related Questions
GUI.FocusControl & GUI.SetNextControlName doesn't work 2 Answers
How to focus on TextField2 when TextField1 is compeleted 1 Answer
Can't Input when focus a text field 2 Answers
Using GUI.FocusControl on TextField selects all text 4 Answers
TextField, Event.current, Input.GetKey, and GUI.FocusControl locking 1 Answer