]> git.saurik.com Git - wxWidgets.git/commitdiff
clicking on a panel without children should give it the focus (closes 215436)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 31 May 2003 17:25:07 +0000 (17:25 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 31 May 2003 17:25:07 +0000 (17:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20781 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/containr.cpp

index 5f251fda7b828ebd6de91fd2eb9190b6cadffa87..6262adfd24d32931216fa0e418711ea18fe5eaf8 100644 (file)
@@ -51,10 +51,16 @@ 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;
+
         while ( node )
         {
             wxWindow *child = node->GetData();
@@ -398,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;
         }