Suppress focus loss on opening combobox popup in wxGTK

Make GTKHandleFocusOut() virtual and override it in wxChoice in order to
avoid generating wxEVT_KILL_FOCUS events when the combobox dropdown
button is clicked.

This is important because it allows fatal problems when using a
combobox-based in-place editor in wxDataViewCtrl as getting these events
totally broke the UI before.

See #17034.
This commit is contained in:
Vadim Zeitlin
2018-02-04 00:05:48 +01:00
parent 1148b2e0fe
commit 508a409f7e
4 changed files with 20 additions and 1 deletions

View File

@@ -111,6 +111,23 @@ wxChoice::~wxChoice()
#endif // __WXGTK3__
}
bool wxChoice::GTKHandleFocusOut()
{
if ( wx_is_at_least_gtk2(10) )
{
gboolean isShown;
g_object_get( m_widget, "popup-shown", &isShown, NULL );
// Don't send "focus lost" events if the focus is grabbed by our own
// popup, it counts as part of this window, even though wx doesn't know
// about it (and can't, because GtkComboBox doesn't expose it).
if ( isShown )
return true;
}
return wxChoiceBase::GTKHandleFocusOut();
}
void wxChoice::GTKInsertComboBoxTextItem( unsigned int n, const wxString& text )
{
#ifdef __WXGTK3__