- Home /
event use bug
i try to catch the Return key to change field in a form. my problem is that event.current.use() don't consum the enter key.
what did i do wrong ??? here is my code (MyWindow.cs) in Assets\Editor
// C# example:
using UnityEngine;
using UnityEditor;
public class MyWindow : EditorWindow {
string name = "name";
string Password = "pass";
// Add menu named "My Window" to the Window menu
[MenuItem ("Window/My Window")]
static void Init () {
// Get existing open window or if none, make a new one:
MyWindow window = (MyWindow)EditorWindow.GetWindow (typeof (MyWindow));
}
void OnGUI () {
EditorGUI.LabelField(new Rect(3,40,100,15),"name:");
GUI.SetNextControlName("name");
name = EditorGUI.TextArea (new Rect(113,40,300,15),name);
EditorGUI.LabelField(new Rect(3,60,100,15),"Password:");
GUI.SetNextControlName("password");
Password = EditorGUI.TextArea (new Rect(113,60,300,15),Password);
if(GUI.GetNameOfFocusedControl()=="name" && Event.current.keyCode == KeyCode.Return)
{
Event.current.Use();
GUI.FocusControl("password");
Event.current.Use();
}
}
}
Comment
Your answer
Follow this Question
Related Questions
WebCamTexture performance issue. 1 Answer
Debug Console doesnt show up 7 Answers
Unity3D gibberish in menus 1 Answer
Editor menus are invisible 1 Answer