From eb10b04a3a65a02dbc3e887fa27fe9df70abff35 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 17 Jun 2009 16:32:56 +0000 Subject: [PATCH] Avoid accidental enabling of disabled windows by checking for disabled parent git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@61091 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/window.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 7b2176a7dc..f082d735f7 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -1381,6 +1381,17 @@ bool wxWindowMac::MacCanFocus() const } } +static bool wxIsWindowOrParentDisabled(wxWindow* w) +{ + while (w && !w->IsTopLevel()) + { + if (!w->IsEnabled()) + return true; + w = w->GetParent(); + } + return false; +} + void wxWindowMac::SetFocus() { if ( m_peer == NULL ) @@ -1389,6 +1400,9 @@ void wxWindowMac::SetFocus() if ( !AcceptsFocus() ) return ; + if (wxIsWindowOrParentDisabled(this)) + return; + wxWindow* former = FindFocus() ; if ( former == this ) return ;