Search code examples
wxwidgets

Does wxWidgets provide Search/Filter Dropdown?


Here is a demo of Search/Filter Dropdown. I'm wondering if wxWidgets provides this UI widget.

At this moment, the closest I get is wxOwnerDrawnComboBox, but it doesn't show the dropdown until we press Alt-down on it.

A Search/Filter Dropdown is supposed to show (and update) its dropdown while the user is typing.

Assume we have a wxOwnerDrawnComboBox named X, and its data member m_text which is a wxTextCtrl. If we call X's method Popup to show its popup/dropdown when X's wxEVT_TEXT occurs, m_text will lose the keyboard focus to the popup. The user can no longer input in m_text. If we call m_text->SetFocus(); in the wxEVT_TEXT callback to force the keyboard focus to go back to m_text, it goes even worse: Everything looks frozen, until the user presses double Esc and a runtime-error occurs:

src/common/popupcmn.cpp(313): assert "!m_handlerFocus || !m_handlerFocus->GetNextHandler()" failed in Popup().

Any suggestion? Does wxWidgets provide Search/Filter Dropdown? If "no", is there a 3rd-party Search/Filter Dropdown widget? If "no" again, which direction to implement it? Thanks.


Solution

  • There is nothing exactly like this in wxWidgets. You could use wxSearchCtrl with some extra control or you could use wxTextCtrl::AutoComplete() to use the platform native auto-completion support, but if you want to have something exactly like your demo, you would indeed need to implement it yourself.

    And yes, basing your implementation on wxOwnerDrawnComboBox should work, you may just need to use CallAfter() to avoid focus-related problems. But it's impossible to be sure without seeing your code in details.