vain0x / DotNetKit.Wpf.AutoCompleteComboBox

ComboBox with filtering (auto-complete) for WPF
MIT License
71 stars 26 forks source link

Pass the enter key event somehow? #21

Closed HubKing closed 3 years ago

HubKing commented 3 years ago

I had been using the KeyDown event so then when I press enter in the combobox, it can start searching. Now that the first enter key input is consumed by the AutoCompleteComboBox control itself, I have to press enter twice. I mean, in Google Search, you can just select an item in the suggestion and it starts searching immediately, without your pressing enter again.

The solution I have thought of is having a new event for "input confirmed". That is, when the user just types something and presses enter, this event is raised with the text that the user typed. When the user types something and presses the arrow keys to select an item in the autocomplete list and presses enter, this event should also be raised with the selected list item's text.

vain0x commented 3 years ago

Thanks for comment.

I think "input confirmed" event can be implemented outside of the library because it occurs when:

HubKing commented 3 years ago

SelectionChanged is not usable because it happens when the user presses arrows keys in the completion list. DropDownClosed can be used with that logic, but it also gets raised if I close the drop-down with an item selected but without pressing enter, like:

And of course, I also have to separately handle the Enter-press like before. So, the code gets dirty. I think I may be able to make it work by adding more codes to check the conditions somehow, but it is not as clean as if it has one "input confirmed" event.