From 3c29b3d0ce20df8246a32e8eaa3ed612c4fd720e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 13 Jan 2018 22:50:26 +0100 Subject: [PATCH] Don't disable wxStaticBox children at wx level when disabling it Calling Enable() on all children from wxStaticBox::Enable() was wrong, the actual status of the child, returned by wxWindow::IsThisEnabled(), is not supposed to change just because its parent was disabled. Call NotifyWindowOnEnableChange() to avoid this, while still disabling the children visually. --- include/wx/window.h | 10 +++++----- src/common/statboxcmn.cpp | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/wx/window.h b/include/wx/window.h index 8046223a4a..b8d9e8d1a3 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -1580,6 +1580,11 @@ public: return false; } + // Recursively call our own and our children DoEnable() when the + // enabled/disabled status changed because a parent window had been + // enabled/disabled. This is only used by the library implementation. + void NotifyWindowOnEnableChange(bool enabled); + protected: // helper for the derived class Create() methods: the first overload, with @@ -1891,11 +1896,6 @@ protected: static void NotifyCaptureLost(); private: - // recursively call our own and our children DoEnable() when the - // enabled/disabled status changed because a parent window had been - // enabled/disabled - void NotifyWindowOnEnableChange(bool enabled); - #if wxUSE_MENUS // temporary event handlers used by GetPopupMenuSelectionFromUser() void InternalOnPopupMenu(wxCommandEvent& event); diff --git a/src/common/statboxcmn.cpp b/src/common/statboxcmn.cpp index 0e77dfe74f..8620d4efd0 100644 --- a/src/common/statboxcmn.cpp +++ b/src/common/statboxcmn.cpp @@ -105,11 +105,15 @@ bool wxStaticBoxBase::Enable(bool enable) ++i ) { if ( *i != m_labelWin ) - (*i)->Enable(enable); + (*i)->NotifyWindowOnEnableChange(enable); } m_isEnabled = enable; + // Notice that we don't call DoEnable() on the box itself: under MSW it + // doesn't actually change anything and under GTK this would disable + // the label window. + return true; } #endif // wxHAS_WINDOW_LABEL_IN_STATIC_BOX