From 00a399c062ce76fbfa9ea0bc2c208a9a144a7528 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 31 Mar 2013 01:12:21 +0000 Subject: [PATCH] Remove wxTextCtrl::OnEnabled() hack from wxGTK. Don't change the background colour when the control is being enabled or disabled, it doesn't seem necessary and it's unclear why was this added by r10179 in the first place. It does result in problems however as it could somehow make the selection of wxTextCtrl invisible when it lost focus and so fixes a serious usability problem which happened to all wxTextCtrls for which a wxEVT_UPDATE_UI handler using wxUpdateUIEvent::Enable() was defined. Closes #14898. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73756 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/textctrl.h | 5 ----- include/wx/gtk1/textctrl.h | 5 ----- include/wx/window.h | 7 +------ src/common/wincmn.cpp | 7 ++----- src/gtk/textctrl.cpp | 20 -------------------- src/gtk1/textctrl.cpp | 23 ----------------------- src/osx/window_osx.cpp | 1 - 7 files changed, 3 insertions(+), 65 deletions(-) diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 15e44703da..5db8cb09e7 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -145,11 +145,6 @@ public: GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); protected: - // wxGTK-specific: called recursively by Enable, - // to give widgets an oppprtunity to correct their colours after they - // have been changed by Enable - virtual void OnEnabled(bool enable); - // overridden wxWindow virtual methods virtual wxSize DoGetBestSize() const; virtual void DoApplyWidgetStyle(GtkRcStyle *style); diff --git a/include/wx/gtk1/textctrl.h b/include/wx/gtk1/textctrl.h index c594bc46b2..de6a4034f1 100644 --- a/include/wx/gtk1/textctrl.h +++ b/include/wx/gtk1/textctrl.h @@ -143,11 +143,6 @@ public: // implementation only from now on - // wxGTK-specific: called recursively by Enable, - // to give widgets an oppprtunity to correct their colours after they - // have been changed by Enable - virtual void OnEnabled( bool enabled ) ; - // tell the control to ignore next text changed signal void IgnoreNextTextUpdate(); diff --git a/include/wx/window.h b/include/wx/window.h index 443f0366e7..22f7a5b0ee 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -1511,11 +1511,6 @@ protected: // widgets state are necessary virtual void DoEnable(bool WXUNUSED(enable)) { } - // called when the on-screen widget state changes and provides an - // an opportunity for the widget to update its visual state (colours, - // fonts, anything else) as necessary - virtual void OnEnabled(bool WXUNUSED(enabled)) { } - // the window id - a number which uniquely identifies a window among // its siblings unless it is wxID_ANY @@ -1768,7 +1763,7 @@ protected: static void NotifyCaptureLost(); private: - // recursively call our own and our children OnEnabled() when the + // 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); diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index ff653cb830..5e5a2c83be 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1149,8 +1149,6 @@ void wxWindowBase::NotifyWindowOnEnableChange(bool enabled) DoEnable(enabled); #endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT) - OnEnabled(enabled); - // Disabling a top level window is typically done when showing a modal // dialog and we don't need to disable its children in this case, they will // be logically disabled anyhow (i.e. their IsEnabled() will return false) @@ -1166,9 +1164,7 @@ void wxWindowBase::NotifyWindowOnEnableChange(bool enabled) // they would still show as enabled even though they wouldn't actually // accept any input (at least under MSW where children don't accept input // if any of the windows in their parent chain is enabled). - // - // Notice that we must do this even for wxHAS_NATIVE_ENABLED_MANAGEMENT - // platforms as we still need to call the children OnEnabled() recursively. +#ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) @@ -1177,6 +1173,7 @@ void wxWindowBase::NotifyWindowOnEnableChange(bool enabled) if ( !child->IsTopLevel() && child->IsThisEnabled() ) child->NotifyWindowOnEnableChange(enabled); } +#endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT) } bool wxWindowBase::Enable(bool enable) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index cd1e766045..629a6fbfae 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1341,26 +1341,6 @@ bool wxTextCtrl::Enable( bool enable ) return true; } -// wxGTK-specific: called recursively by Enable, -// to give widgets an opportunity to correct their colours after they -// have been changed by Enable -void wxTextCtrl::OnEnabled(bool WXUNUSED(enable)) -{ - // If we have a custom background colour, we use this colour in both - // disabled and enabled mode, or we end up with a different colour under the - // text. - wxColour oldColour = GetBackgroundColour(); - if (oldColour.IsOk()) - { - // Need to set twice or it'll optimize the useful stuff out - if (oldColour == * wxWHITE) - SetBackgroundColour(*wxBLACK); - else - SetBackgroundColour(*wxWHITE); - SetBackgroundColour(oldColour); - } -} - void wxTextCtrl::MarkDirty() { m_modified = true; diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 7ce0d35e3d..fd777b6b3d 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -714,29 +714,6 @@ void wxTextCtrl::DoEnable( bool enable ) } } -// wxGTK-specific: called recursively by Enable, -// to give widgets an oppprtunity to correct their colours after they -// have been changed by Enable -void wxTextCtrl::OnEnabled( bool WXUNUSED(enable) ) -{ - if ( IsSingleLine() ) - return; - - // If we have a custom background colour, we use this colour in both - // disabled and enabled mode, or we end up with a different colour under the - // text. - wxColour oldColour = GetBackgroundColour(); - if (oldColour.IsOk()) - { - // Need to set twice or it'll optimize the useful stuff out - if (oldColour == * wxWHITE) - SetBackgroundColour(*wxBLACK); - else - SetBackgroundColour(*wxWHITE); - SetBackgroundColour(oldColour); - } -} - void wxTextCtrl::MarkDirty() { m_modified = true; diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index d7ef17acce..cd7a53c8aa 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1304,7 +1304,6 @@ void wxWindowMac::MacHiliteChanged() void wxWindowMac::MacEnabledStateChanged() { - OnEnabled( GetPeer()->IsEnabled() ); } // -- 2.45.2