Coalesce wxEVT_TEXT events in wxGTK wxTextCtrl and wxComboBox

For consistency with the other platforms, coalesce multiple wxEVT_TEXT
events resulting from a single user action into a single one in wxGTK
too. For example, when pressing a key in a control with some text
selected, wxGTK previously generated 2 wxEVT_TEXT events: one
corresponding to the removal of the selection and another one to the
addition of the new text. Now only a single event with the new text is
generated, as in the other ports.

Doing this requires delaying sending wxEVT_TEXT until GTK itself ends
handling the key press, however we delay it as little as possible, so
hopefully this shouldn't have any visible effects at wx API level.

Closes #10050.
This commit is contained in:
Vadim Zeitlin
2019-07-10 02:14:21 +02:00
parent 958df5fb74
commit 2c6dcc2e51
3 changed files with 141 additions and 2 deletions

View File

@@ -858,7 +858,11 @@ GtkEntry *wxTextCtrl::GetEntry() const
int wxTextCtrl::GTKIMFilterKeypress(GdkEventKey* event) const
{
if (IsSingleLine())
return wxTextEntry::GTKIMFilterKeypress(event);
return GTKEntryIMFilterKeypress(event);
// When not calling GTKEntryIMFilterKeypress(), we need to notify the code
// in wxTextEntry about the key presses explicitly.
GTKEntryOnKeypress(m_text);
int result = false;
#if GTK_CHECK_VERSION(2, 22, 0)