Hi,
I’ve been reading about this a lot, but I can’t seem to find any solution. I’m doing a quick editor extension, and the user needs to be able to make a tab in the textarea. However, unity cycles through all textfields with tab. I’m looking for a way to disable that. As far as I’ve read, you can’t. This:
if (Event.current.keyCode == KeyCode.Tab)
{
Event.current.Use();
}
does catch the event, but doesn’t prevent it. I can set back focus manually though. My idea was to insert a tab at the cursor position, but I can’t seem to get that either. I’m using the following code:
GUI.SetNextControlName("TextArea");
string newValue = EditorGUILayout.TextArea(p.stringValue, GUILayout.MinHeight(50.0f));
TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
if (Event.current.keyCode == KeyCode.Tab)
{
GUI.FocusControl("TextArea");
newValue.Insert(editor.pos, "\t");
editor.SelectNone();
Event.current.Use();
}
Editor.pos is always 0 though ![]()
Any help would be greatly appreciated!