private void DrawSearch(Rect rect)
 {
     GUI.Label(rect, "", EditorStyles.toolbar);
     if (list.UpdateFilter(searchField.OnGUI(rect.Zoom(AnchorType.MiddleCenter, -2), list.Filter)))
     {
         hoverIndex = 0;
         scroll     = Vector2.zero;
     }
 }
        private void DrawSearch(Rect rect)
        {
            if (Event.current.type == EventType.Repaint)
            {
                EditorStyles.toolbar.Draw
                (
                    rect, false, false, false,
                    false
                );
            }

            Rect searchRect = new Rect(rect);

            searchRect.xMin  += 6;
            searchRect.xMax  -= 6;
            searchRect.y     += 2;
            searchRect.width -= CancelButton.fixedWidth;

            GUI.FocusControl(SEARCH_CONTROL_NAME);
            GUI.SetNextControlName(SEARCH_CONTROL_NAME);
            string newText = GUI.TextField(searchRect, list.Filter, SearchBox);

            if (list.UpdateFilter(newText))
            {
                hoverIndex = 0;
                scroll     = Vector2.zero;
            }

            searchRect.x     = searchRect.xMax;
            searchRect.width = CancelButton.fixedWidth;

            if (string.IsNullOrEmpty(list.Filter))
            {
                GUI.Box(searchRect, GUIContent.none, DisabledCancelButton);
            }
            else if (GUI.Button(searchRect, "x", CancelButton))
            {
                list.UpdateFilter("");
                scroll = Vector2.zero;
            }
        }
Exemple #3
0
        void DrawSearch(Rect rect)
        {
            if (Event.current.type == EventType.Repaint)
            {
                EditorStyles.toolbar.Draw(rect, false, false, false, false);
            }

            Rect searchRect = new Rect(rect);

            searchRect.xMin  += 6;
            searchRect.xMax  -= 6;
            searchRect.y     += 2;
            searchRect.width -= s_CancelButton.fixedWidth;

            GUI.FocusControl(k_SearchControlName);
            GUI.SetNextControlName(k_SearchControlName);
            string newText = GUI.TextField(searchRect, m_List.Filter, s_SearchBox);

            if (m_List.UpdateFilter(newText))
            {
                m_HoverIndex = 0;
                m_Scroll     = Vector2.zero;
            }

            searchRect.x     = searchRect.xMax;
            searchRect.width = s_CancelButton.fixedWidth;

            if (string.IsNullOrEmpty(m_List.Filter))
            {
                GUI.Box(searchRect, GUIContent.none, s_DisabledCancelButton);
            }
            else if (GUI.Button(searchRect, "x", s_CancelButton))
            {
                m_List.UpdateFilter("");
                m_Scroll = Vector2.zero;
            }
        }