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: Code (csharp): 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: Code (csharp): 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!
Actually, it is possible, from https://forum.unity.com/threads/how-to-disable-the-tab-key-event.90440/ Code (CSharp): if (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t') Event.current.Use();
Thanks for registering a new account to necropost a 6 year old post and answer a question that's relevant only to obsolete versions of Unity UI's. /s
Always a pleasure! Thank you for your post, it is really a quality one and brings lot of value to all of us. And actually, I posted it because I had problems with capturing tab in Unity 2018.3.... It was relevant to me, and could be relevant to somebody else (not you, obviously).