]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix bug with not selecting wxAuiNotebook page when its child was focused.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 6 Sep 2013 12:27:04 +0000 (12:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 6 Sep 2013 12:27:04 +0000 (12:27 +0000)
The code in OnChildFocusNotebook() handler only worked correctly if the page
itself was focused but not if the focus was given to one of its children --
which should still make the page itself current.

Closes #15471.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74769 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/aui/auibook.cpp

index fb3d540a8488c6aba6c308db25942dd7e9c65a9e..2d1787ee0ade522452545cdb6bd25258bddb5de3 100644 (file)
@@ -2993,9 +2993,21 @@ void wxAuiNotebook::OnChildFocusNotebook(wxChildFocusEvent& evt)
     }
 
 
-    // change the tab selection to the child
-    // which was focused
-    int idx = m_tabs.GetIdxFromWindow(evt.GetWindow());
+    // find the page containing the focused child
+    wxWindow* win = evt.GetWindow();
+    while ( win )
+    {
+        // pages have the notebook as the parent, so stop when we reach one
+        // (and also stop in the impossible case of no parent at all)
+        wxWindow* const parent = win->GetParent();
+        if ( !parent || parent == this )
+            break;
+
+        win = parent;
+    }
+
+    // change the tab selection to this page
+    int idx = m_tabs.GetIdxFromWindow(win);
     if (idx != -1 && idx != m_curPage)
     {
         SetSelection(idx);