Exemplo n.º 1
0
 public QueryBuilder(SearchContext searchContext, UI.SearchField searchField = null)
     : this()
 {
     m_Context     = searchContext;
     m_SearchField = searchField;
     Build();
 }
Exemplo n.º 2
0
 public QueryTextFieldBlock(IQuerySource source, UI.SearchField searchField)
     : base(source)
 {
     hideMenu      = true;
     value         = string.Empty;
     m_SearchField = searchField;
 }
Exemplo n.º 3
0
        public static string Draw(UI.SearchField searchField)
        {
            if (!enabled)
            {
                return(null);
            }

            var evt = Event.current;

            if (evt.type == EventType.MouseDown && !position.Contains(evt.mousePosition))
            {
                evt.Use();
                Clear();
                return(null);
            }

            var te         = searchField.GetTextEditor();
            var searchText = te.text;

            // Check if the cache filtered list should be updated
            if (evt.type == EventType.Repaint && !searchText.Equals(s_LastInput, StringComparison.Ordinal))
            {
                UpdateCompleteList(searchField.GetTextEditor());
            }

            if (s_FilteredList == null)
            {
                return(null);
            }

            var selected = DrawItems(evt, out var proposition);

            if (proposition.valid)
            {
                if (proposition.moveCursor == TextCursorPlacement.MoveLineEnd)
                {
                    te.text = proposition.replacement;
                    te.MoveLineEnd();
                    GUI.changed = true;
                }
                else if (!options.tokens.All(t => t.StartsWith(proposition.replacement, StringComparison.OrdinalIgnoreCase)))
                {
                    var insertion = ReplaceText(searchText, proposition.replacement, options.cursor, out var insertTokenPos);
                    SearchAnalytics.SendEvent(null, SearchAnalytics.GenericEventType.QuickSearchAutoCompleteInsertSuggestion, insertion);

                    te.text = insertion;
                    searchField.MoveCursor(proposition.moveCursor, insertTokenPos);
                    GUI.changed = true;
                }
            }

            if (selected)
            {
                // No more results
                Clear();
            }

            return(te.text);
        }
Exemplo n.º 4
0
 internal void OnEnable()
 {
     m_SearchField = new UI.SearchField();
     if (!string.IsNullOrEmpty(m_ReportPath))
     {
         InitializeReport(m_ReportPath);
     }
 }
Exemplo n.º 5
0
        public static bool Show(SearchContext context, Rect parentRect, UI.SearchField searchField)
        {
            var te = searchField.GetTextEditor();

            if (te.controlID != GUIUtility.keyboardControl)
            {
                return(false);
            }

            parent       = parentRect;
            options      = new SearchPropositionOptions(context, te.cursorIndex, te.text);
            propositions = SearchProposition.Fetch(context, options);

            enabled = propositions.Count > 0;
            if (!enabled)
            {
                return(false);
            }

            SearchAnalytics.SendEvent(null, SearchAnalytics.GenericEventType.QuickSearchAutoCompleteTab, string.Join(",", options.tokens));
            UpdateCompleteList(te, options);
            return(true);
        }