diff --git a/include/wx/containr.h b/include/wx/containr.h index c9eb5857c5..aa5ffd625c 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -44,9 +44,6 @@ public: // By default, we accept focus ourselves. m_acceptsFocusSelf = true; - // But we don't have any children accepting it yet. - m_acceptsFocusChildren = false; - m_inSetFocus = false; m_winLastFocused = NULL; } @@ -79,8 +76,7 @@ public: // Returns whether we or one of our children accepts focus. bool AcceptsFocusRecursively() const - { return AcceptsFocus() || - (m_acceptsFocusChildren && HasAnyChildrenAcceptingFocus()); } + { return AcceptsFocus() || HasAnyChildrenAcceptingFocus(); } // We accept focus from keyboard if we accept it at all. bool AcceptsFocusFromKeyboard() const { return AcceptsFocusRecursively(); } @@ -119,7 +115,11 @@ protected: private: // Update the window status to reflect whether it is getting focus or not. - void UpdateParentCanFocus(); + void UpdateParentCanFocus(bool acceptsFocusChildren); + void UpdateParentCanFocus() + { + UpdateParentCanFocus(HasAnyFocusableChildren()); + } // Indicates whether the associated window can ever have focus itself. // @@ -129,9 +129,6 @@ private: // ourselves and can only get it if we have any focusable children. bool m_acceptsFocusSelf; - // Cached value remembering whether we have any children accepting focus. - bool m_acceptsFocusChildren; - // a guard against infinite recursion bool m_inSetFocus; }; diff --git a/src/common/containr.cpp b/src/common/containr.cpp index bdf72218af..196ada8172 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -50,25 +50,21 @@ // wxControlContainerBase // ---------------------------------------------------------------------------- -void wxControlContainerBase::UpdateParentCanFocus() +void wxControlContainerBase::UpdateParentCanFocus(bool acceptsFocusChildren) { // In the ports where it does something non trivial, the parent window // should only be focusable if it doesn't have any focusable children // (e.g. native focus handling in wxGTK totally breaks down otherwise). - m_winParent->SetCanFocus(m_acceptsFocusSelf && !m_acceptsFocusChildren); + m_winParent->SetCanFocus(m_acceptsFocusSelf && !acceptsFocusChildren); } bool wxControlContainerBase::UpdateCanFocusChildren() { const bool acceptsFocusChildren = HasAnyFocusableChildren(); - if ( acceptsFocusChildren != m_acceptsFocusChildren ) - { - m_acceptsFocusChildren = acceptsFocusChildren; - UpdateParentCanFocus(); - } + UpdateParentCanFocus(acceptsFocusChildren); - return m_acceptsFocusChildren; + return acceptsFocusChildren; } bool wxControlContainerBase::HasAnyFocusableChildren() const