private void OnLabelMouseDown(MouseDownEvent evt) { var pickedLabel = evt.target as VisualElement; var suggestOption = (SuggestOption)pickedLabel.userData; OnSuggestedSelected?.Invoke(suggestOption); textEntry.SetValueWithoutNotify(""); hasFocus = false; UpdateVisibility(); }
private void OnKeyDown(KeyDownEvent evt) { switch (evt.keyCode) { case KeyCode.Return: case KeyCode.KeypadEnter: var suggestOption = MatchedSuggestOption[optionList.selectedIndex]; OnSuggestedSelected?.Invoke(suggestOption); textEntry.SetValueWithoutNotify(""); hasFocus = false; UpdateVisibility(); return; case KeyCode.UpArrow: evt.PreventDefault(); if (optionList.selectedIndex > 0) { optionList.selectedIndex--; } break; case KeyCode.DownArrow: evt.PreventDefault(); if (optionList.selectedIndex < MatchedSuggestOption.Count - 1) { optionList.selectedIndex++; } break; default: optionList.selectedIndex = -1; break; } optionList.ScrollToItem(optionList.selectedIndex); }