]> git.saurik.com Git - wxWidgets.git/commitdiff
Postpone showing the notebook pages under wxOSX/Cocoa.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 24 Jul 2010 12:27:29 +0000 (12:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 24 Jul 2010 12:27:29 +0000 (12:27 +0000)
Showing the selected notebook page immediately when it's selected can result
in the top level parent of the notebook being shown prematurely, so don't do
this until the notebook itself is shown.

Closes #12227.

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

src/osx/notebook_osx.cpp

index dad2a6c5c49fb473d23e3dd6fcd1a5d2e3034f9f..95dfb988b4412da810d693af67d2c371e48cbcd2 100644 (file)
@@ -378,6 +378,20 @@ void wxNotebook::OnSize(wxSizeEvent& event)
             pPage->Layout();
     }
 
+    // If the selected page is hidden at this point, the notebook
+    // has become visible for the first time after creation, and
+    // we postponed showing the page in ChangePage().
+    // So show the selected page now.
+    if ( m_nSelection != -1 )
+    {
+        wxNotebookPage *pPage = m_pages[m_nSelection];
+        if ( !pPage->IsShown() )
+        {
+            pPage->Show( true );
+            pPage->SetFocus();
+        }
+    }
+
     // Processing continues to next OnSize
     event.Skip();
 }
@@ -502,8 +516,20 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
     if ( nSel != -1 )
     {
         wxNotebookPage *pPage = m_pages[nSel];
-        pPage->Show( true );
-        pPage->SetFocus();
+        if ( IsShownOnScreen() )
+        {
+            pPage->Show( true );
+            pPage->SetFocus();
+        }
+        else
+        {
+            // Postpone Show() until the control is actually shown.
+            // Otherwise this forces the containing toplevel window
+            // to show, even if it's just being created and called
+            // AddPage() without intent to show the window yet.
+            // We Show() the selected page in our OnSize handler,
+            // unless it already is shown.
+        }
     }
 
     m_nSelection = nSel;