Skip to content

Commit 32750c7

Browse files
author
Markus
committed
add some QOL Features to the CategorizedEnumPopup
1 parent da8ef67 commit 32750c7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Editor/CategorizedEnumPopup.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public CategorizedEnumPopup(char delimiter, bool showFullPath, string[] enumName
4949

5050
// setup the search field
5151
searchField = new SearchField();
52-
searchField.downOrUpArrowKeyPressed += treeView.SetFocus;
52+
searchField.downOrUpArrowKeyPressed += treeView.SetFocusAndEnsureSelectedItem;
5353
searchField.SetFocus();
5454

5555
// set the window width that should be used.
@@ -131,6 +131,14 @@ public override void OnGUI(Rect rect) {
131131
GUI.FocusControl("searchString");
132132
firstRun = false;
133133
}
134+
135+
// close window on pressing esc or enter (enter only when searchfield has no focus)
136+
Event ev = Event.current;
137+
if ((ev.type == EventType.KeyDown || ev.type == EventType.KeyUp) && (ev.keyCode == KeyCode.Escape || ev.keyCode == KeyCode.Return)) {
138+
if (ev.keyCode != KeyCode.Return || !searchField.HasFocus()) {
139+
editorWindow.Close();
140+
}
141+
}
134142
}
135143
}
136144
}

0 commit comments

Comments
 (0)