Merge branch 'gtk-combo-focus'
Fix spurious focus loss events for wxGTK comboboxes. See https://github.com/wxWidgets/wxWidgets/pull/714
This commit is contained in:
@@ -207,6 +207,7 @@ wxGTK:
|
||||
- Implement XYToPosition() for single-line wxTextCtrl.
|
||||
- Implement ShowPosition() for single-line wxTextCtrl.
|
||||
- Improve wx{Client,Paint,Screen,Window}DC::GetPPI() (GTK+ 3).
|
||||
- Suppress focus loss events for wxChoice and wxComboBox on opening popup.
|
||||
|
||||
wxMSW:
|
||||
|
||||
|
@@ -101,6 +101,7 @@ protected:
|
||||
virtual void DoClear() wxOVERRIDE;
|
||||
virtual void DoDeleteOneItem(unsigned int n) wxOVERRIDE;
|
||||
|
||||
virtual bool GTKHandleFocusOut() wxOVERRIDE;
|
||||
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const wxOVERRIDE;
|
||||
virtual void DoApplyWidgetStyle(GtkRcStyle *style) wxOVERRIDE;
|
||||
|
||||
|
@@ -197,9 +197,9 @@ public:
|
||||
GdkWindow* GTKGetDrawingWindow() const;
|
||||
|
||||
bool GTKHandleFocusIn();
|
||||
bool GTKHandleFocusOut();
|
||||
virtual bool GTKHandleFocusOut();
|
||||
void GTKHandleFocusOutNoDeferring();
|
||||
static void GTKHandleDeferredFocusOut();
|
||||
void GTKHandleDeferredFocusOut();
|
||||
|
||||
// Called when m_widget becomes realized. Derived classes must call the
|
||||
// base class method if they override it.
|
||||
|
@@ -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__
|
||||
|
@@ -3828,7 +3828,7 @@ bool wxWindowGTK::GTKShowFromOnIdle()
|
||||
void wxWindowGTK::OnInternalIdle()
|
||||
{
|
||||
if ( gs_deferredFocusOut )
|
||||
GTKHandleDeferredFocusOut();
|
||||
gs_deferredFocusOut->GTKHandleDeferredFocusOut();
|
||||
|
||||
// Check if we have to show window now
|
||||
if (GTKShowFromOnIdle()) return;
|
||||
@@ -4348,7 +4348,7 @@ bool wxWindowGTK::GTKHandleFocusIn()
|
||||
// otherwise we need to send focus-out first
|
||||
wxASSERT_MSG ( gs_deferredFocusOut != this,
|
||||
"GTKHandleFocusIn(GTKFocus_Normal) called even though focus changed back to itself - derived class should handle this" );
|
||||
GTKHandleDeferredFocusOut();
|
||||
gs_deferredFocusOut->GTKHandleDeferredFocusOut();
|
||||
}
|
||||
|
||||
|
||||
@@ -4459,23 +4459,18 @@ void wxWindowGTK::GTKHandleFocusOutNoDeferring()
|
||||
GTKProcessEvent( event );
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void wxWindowGTK::GTKHandleDeferredFocusOut()
|
||||
{
|
||||
// NB: See GTKHandleFocusOut() for explanation. This function is called
|
||||
// from either GTKHandleFocusIn() or OnInternalIdle() to process
|
||||
// deferred event.
|
||||
if ( gs_deferredFocusOut )
|
||||
{
|
||||
wxWindowGTK *win = gs_deferredFocusOut;
|
||||
gs_deferredFocusOut = NULL;
|
||||
// deferred event for this window.
|
||||
gs_deferredFocusOut = NULL;
|
||||
|
||||
wxLogTrace(TRACE_FOCUS,
|
||||
"processing deferred focus_out event for %s(%p, %s)",
|
||||
win->GetClassInfo()->GetClassName(), win, win->GetLabel());
|
||||
wxLogTrace(TRACE_FOCUS,
|
||||
"processing deferred focus_out event for %s(%p, %s)",
|
||||
GetClassInfo()->GetClassName(), this, GetLabel());
|
||||
|
||||
win->GTKHandleFocusOutNoDeferring();
|
||||
}
|
||||
GTKHandleFocusOutNoDeferring();
|
||||
}
|
||||
|
||||
void wxWindowGTK::SetFocus()
|
||||
|
Reference in New Issue
Block a user