private string DrawSearchField(Rect innerToolbarArea, string searchText) { (Rect searchFieldArea, Rect buttonRect) = innerToolbarArea.CutVertically(DropdownStyle.IconSize, true); bool keyDown = Event.current.type == EventType.KeyDown; searchText = EditorGUIHelper.FocusedTextField(searchFieldArea, searchText, "Search", DropdownStyle.SearchToolbarStyle, _searchFieldControlName); // When the search field is in focus, it uses the keyDown event on DownArrow while doing nothing. // We need this event for moving through the tree nodes. if (keyDown) { Event.current.type = EventType.KeyDown; } if (GUIHelper.CloseButton(buttonRect)) { searchText = string.Empty; GUI.FocusControl(null); // Without this, the old text does not disappear for some reason. GUI.changed = true; } return(searchText); }