I have an issue concerning wxWidgets 2.9 and the wxComboBox AutoComplete feature. Below is my event table which takes the ENTER event of my ComboBox, on enter I fire OnComboEnter. If I do that I’m not able to select an item from the AutoComplete list since it directly executes the OnComboEnter method on the text the user typed into the ComboBox.
BEGIN_EVENT_TABLE(LVFilterPanel, wxPanel)
EVT_TEXT_ENTER(wxID_ANY, LVFilterPanel::OnComboEnter)
EVT_CONTEXT_MENU(LVFilterPanel::OnComboContextMenu)
END_EVENT_TABLE()
My ComboBox is declared like this:
mFilterString = new wxComboBox(this, LV_FILTER_STRING, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, wxTE_PROCESS_ENTER);
AutoComplet is done using the default AutoComplete method found in wxWidgets 2.9:
mFilterString->AutoComplete(historyarr);
historyarr is a wxArrayString filled with the strings which were previously typed in by the user.
The OnComboEnter method looks like this:
void LVFilterPanel::OnComboEnter(wxCommandEvent& event) {
wxCommandEvent ce(wxEVT_COMMAND_BUTTON_CLICKED, LV_FILTER);
static_cast<wxButton*>(FindWindow(LV_FILTER))->Command(ce);
}
My question now is, how could I change the event handling in a way that it is able to select the item first and then processes OnComboEnter, so the user is able to select an item first (or may not select an item at all and directly hit enter to launch the event and the OnComboEnter method).
Thanks in advance.
Greets,
Roin
If you need to execute your event handler after the standard handling takes place, the usual trick is to do nothing in your event handler (which means also calling
event.Skip(), of course!) except setting some internal flag and check this flag inEVT_IDLEhandler. If it is set, then do whatever you need (e.g.button->Command()in your case) and reset the flag.This approach ensures that the handler is ran “soon after” the event happens without interfering with normal event processing.