public Finder( TextField searchField, ISearchLens <T> searchLens, ISearchResultProcessor <T> processor, ISearchResultDisplayer <T, V> displayer, int visibleResults = 10, int indexOfSelection = 0 ) { _searchLens = searchLens; _processor = processor; _displayer = displayer; _resultData = new List <T>(); _selectionPosition = new SelectionPosition(this); NumVisibleResults = visibleResults; if (indexOfSelection >= NumVisibleResults) { throw new ArgumentException("The index of the selection must be less than the number of results."); } IndexOfSelection = indexOfSelection; searchField.RegisterCallback <KeyDownEvent>(HandleSearchFieldInputs); searchField.OnValueChanged(e => UpdateSearch(e.newValue)); _resultDisplay = new ReuseSelectionList <V>( _displayer.MakeElement, (e, i) => _displayer.ApplyData(_currentSearchTerm, e, _resultData, i), new DataSource(_resultData), NumVisibleResults, IndexOfSelection ); _resultDisplay.Container.CheapDisable(); _resultDisplay.Prewarm(); EditorApplication.update += Update; }
public void ShowFinder( ISearchLens <T> searchLens, ISearchResultProcessor <T> processor, ISearchResultDisplayer <T, V> display ) { _finder = new Finder <T, V>( _searchField, searchLens, new CloseProcessor(this, processor), display ); var root = this.GetRootVisualContainer(); root.Add(_finder.Container); _finder.Container.PlaceBehind(_infoLabel); _finder.Container.name = "ResultList"; _finder.SearchStateChanged += OnSearchStateChanged; minSize = new Vector2(1, 1); ShowPopup(); Focus(); }