From: Vadim Zeitlin Date: Thu, 29 Dec 2011 22:05:27 +0000 (+0000) Subject: Better fix for wxSpinCtrlGeneric enabling/disabling bug in wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a2fb9138b2cc4795371bc5d561eee42de39f1a7d?ds=sidebyside Better fix for wxSpinCtrlGeneric enabling/disabling bug in wxMSW. To really ensure that the window containing the components of wxSpinCtrlGeneric is never enabled under MSW (as we want to avoid this to ensure that any input always goes to its children and not the window itself, see #12045), override DoEnable() and not Enable(). This takes care of the case when the control gets implicitly disabled because its parent is. Closes #13142. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70178 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/generic/spinctlg.h b/include/wx/generic/spinctlg.h index 338dd70234..62d2268eff 100644 --- a/include/wx/generic/spinctlg.h +++ b/include/wx/generic/spinctlg.h @@ -108,6 +108,11 @@ protected: virtual wxSize DoGetBestSize() const; virtual void DoMoveWindow(int x, int y, int width, int height); +#ifdef __WXMSW__ + // and, for MSW, enabling this window itself + virtual void DoEnable(bool enable); +#endif // __WXMSW__ + // generic double valued functions double DoGetValue() const { return m_value; } bool DoSetValue(double val); diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index e9a7a32a37..615e64ea24 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -283,16 +283,24 @@ void wxSpinCtrlGenericBase::SetFocus() m_textCtrl->SetFocus(); } +#ifdef __WXMSW__ + +void wxSpinCtrlGenericBase::DoEnable(bool enable) +{ + // We never enable this control itself, it must stay disabled to avoid + // interfering with the siblings event handling (see e.g. #12045 for the + // kind of problems which arise otherwise). + if ( !enable ) + wxSpinCtrlBase::DoEnable(enable); +} + +#endif // __WXMSW__ + bool wxSpinCtrlGenericBase::Enable(bool enable) { - // Notice that we never enable this control itself, it must stay disabled - // to avoid interfering with the siblings event handling (see e.g. #12045 - // for the kind of problems which arise otherwise). - if ( enable == m_isEnabled ) + if ( !wxSpinCtrlBase::Enable(enable) ) return false; - m_isEnabled = enable; - m_spinButton->Enable(enable); m_textCtrl->Enable(enable);