Skip to content

Commit e12f08a

Browse files
committed
feat: auto focus the search field when popup the PlayableGraph list
1 parent 039e91b commit e12f08a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Editor/Scripts/Element/SearchablePopupField.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ public override void OnOpen()
160160

161161
public override void OnGUI(Rect rect)
162162
{
163+
const string SEARCH_CONTROL = "ToolbarSearchField";
164+
163165
EditorGUI.BeginChangeCheck();
164-
_searchContent = EditorGUILayoutHelper.ToolbarSearchField(_searchContent);
166+
{
167+
GUI.SetNextControlName(SEARCH_CONTROL);
168+
_searchContent = EditorGUILayoutHelper.ToolbarSearchField(_searchContent);
169+
EditorGUI.FocusTextInControl(SEARCH_CONTROL);
170+
}
165171
if (EditorGUI.EndChangeCheck())
166172
{
167173
_filteredChoices.Clear();
@@ -187,7 +193,7 @@ public override Vector2 GetWindowSize()
187193
Vector2 size = new Vector2
188194
{
189195
x = Mathf.Max(300, _popup.GetVisualInput().resolvedStyle.width),
190-
y = Mathf.Min(400, _list.elementHeight * _list.count + 28),
196+
y = Mathf.Min(400, _list.elementHeight * _list.count + 36),
191197
};
192198

193199
return size;
@@ -208,7 +214,6 @@ private string GetElementDisplayName(IList<T> elements, int index, bool isActive
208214

209215
private void DrawElementBackground(Rect rect, int index, bool isActive, bool isFocused)
210216
{
211-
// EditorStyles.toolbarPopup
212217
if (isActive)
213218
{
214219
EditorGUI.DrawRect(rect, new Color(0.24f, 0.48f, 0.90f, 0.5f));

0 commit comments

Comments
 (0)