X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..11c084163e3702692586f70a9414dca97bb2a2d6:/src/common/containr.cpp diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 5b5df9ea92..6262adfd24 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -6,7 +6,7 @@ // Created: 06.08.01 // RCS-ID: $Id$ // Copyright: (c) 2001 Vadim Zeitlin -// License: wxWindows license +// License: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -49,6 +49,34 @@ wxControlContainer::wxControlContainer(wxWindow *winParent) m_winDefault = NULL; } +bool wxControlContainer::AcceptsFocus() const +{ + // if we're not shown or disabled, we can't accept focus + if ( m_winParent->IsShown() && m_winParent->IsEnabled() ) + { + // otherwise we can accept focus either if we have no children at all + // (in this case we're probably not used as a container) or only when + // at least one child will accept focus + wxWindowList::Node *node = m_winParent->GetChildren().GetFirst(); + if ( !node ) + return TRUE; + + while ( node ) + { + wxWindow *child = node->GetData(); + + if ( child->AcceptsFocus() ) + { + return TRUE; + } + + node = node->GetNext(); + } + } + + return FALSE; +} + void wxControlContainer::SetLastFocus(wxWindow *win) { // the panel itself should never get the focus at all but if it does happen @@ -376,7 +404,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) _T("SetFocusToChild() => first child (0x%08lx)."), (unsigned long)child->GetHandle()); - *childLastFocused = child; // should be redundant, but it is not + *childLastFocused = child; child->SetFocusFromKbd(); return TRUE; } @@ -386,3 +414,4 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) return FALSE; } +