X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3251b8346678b487755102e2ddb5f2071ee1f1ca..d94974609888885e0b75d0e01d901b03a6213979:/src/common/containr.cpp diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 5f251fda7b..fe1ea94cab 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -36,6 +36,10 @@ #include "wx/containr.h" +#ifdef __WXMAC__ + #include "wx/scrolbar.h" +#endif + // ============================================================================ // implementation // ============================================================================ @@ -51,10 +55,22 @@ wxControlContainer::wxControlContainer(wxWindow *winParent) bool wxControlContainer::AcceptsFocus() const { - // We can accept focus only when at last one child will accept focus + // 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; + +#ifdef __WXMAC__ + // wxMac has eventually the two scrollbars as children, they don't count + // as real children in the algorithm mentioned above + bool hasRealChildren = false ; +#endif + while ( node ) { wxWindow *child = node->GetData(); @@ -64,8 +80,18 @@ bool wxControlContainer::AcceptsFocus() const return TRUE; } +#ifdef __WXMAC__ + wxScrollBar *sb = wxDynamicCast( child , wxScrollBar ) ; + if ( sb == NULL || !m_winParent->MacIsWindowScrollbar( sb ) ) + hasRealChildren = true ; +#endif node = node->GetNext(); } + +#ifdef __WXMAC__ + if ( !hasRealChildren ) + return TRUE ; +#endif } return FALSE; @@ -398,7 +424,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; }