- m_connectedTextChangedEvent = true;
-
- wxBIND_OR_CONNECT_HACK(m_win, wxEVT_COMMAND_TEXT_UPDATED,
- wxCommandEventHandler,
- wxTextAutoCompleteData::OnTextChanged,
+ m_connectedCharEvent = true;
+
+ // Use the special wxEVT_AFTER_CHAR and not the usual
+ // wxEVT_CHAR here because we need to have the updated value of
+ // the text control in this handler in order to provide
+ // completions for the correct prefix and unfortunately we
+ // don't have any way to let DefWindowProc() run from our
+ // wxEVT_CHAR handler (as we must also let the other handlers
+ // defined at wx level run first).
+ //
+ // Notice that we can't use wxEVT_COMMAND_TEXT_UPDATED here
+ // neither as, due to our use of ACO_AUTOAPPEND, we get
+ // EN_CHANGE notifications from the control every time
+ // IAutoComplete auto-appends something to it.
+ wxBIND_OR_CONNECT_HACK(m_win, wxEVT_AFTER_CHAR,
+ wxKeyEventHandler,
+ wxTextAutoCompleteData::OnAfterChar,