]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/frame.cpp
Added code to show off wxDbGrid (contributed by Paul and Roger Gammans) in wxUSE_NEW_...
[wxWidgets.git] / src / mac / carbon / frame.cpp
index 9c06869fcbe0e13c3465fc4a6c83fe18c7a7fc57..bbbef8f74b2d7275e3c0d20525c576e038412644 100644 (file)
@@ -54,6 +54,14 @@ bool wxFrame::m_useNativeStatusBar = FALSE;
 
 void wxFrame::Init()
 {
+  m_frameMenuBar = NULL;
+
+#if wxUSE_TOOLBAR
+  m_frameToolBar = NULL ;
+#endif
+  m_frameStatusBar = NULL;
+  m_winLastFocused = NULL ;
+
     m_iconized = FALSE;
 
 #if wxUSE_TOOLTIPS
@@ -94,13 +102,6 @@ bool wxFrame::Create(wxWindow *parent,
            long style,
            const wxString& name)
 {
-  m_frameMenuBar = NULL;
-
-#if wxUSE_TOOLBAR
-  m_frameToolBar = NULL ;
-#endif
-  m_frameStatusBar = NULL;
-
   SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
 
   if ( id > -1 )
@@ -228,7 +229,6 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar)
         return;
     }
   
-    m_frameMenuBar = NULL;
     m_frameMenuBar = menuBar;
 //    m_frameMenuBar->MacInstallMenuBar() ;
     m_frameMenuBar->Attach(this);
@@ -259,10 +259,21 @@ void wxFrame::OnActivate(wxActivateEvent& event)
 {
     if ( !event.GetActive() )
     {
+       // remember the last focused child
+        m_winLastFocused = FindFocus();
+        while ( m_winLastFocused )
+        {
+            if ( GetChildren().Find(m_winLastFocused) )
+                break;
+
+            m_winLastFocused = m_winLastFocused->GetParent();
+        }
+
         event.Skip();
-        return;
     }
-
+       else
+       {
+/*
     for ( wxWindowList::Node *node = GetChildren().GetFirst();
           node;
           node = node->GetNext() )
@@ -273,7 +284,7 @@ void wxFrame::OnActivate(wxActivateEvent& event)
         // restore focus
         wxWindow *child = node->GetData();
 
-        if ( !child->IsTopLevel()
+        if ( !child->IsTopLevel() && child->AcceptsFocus()
 #if wxUSE_TOOLBAR
              && !wxDynamicCast(child, wxToolBar)
 #endif // wxUSE_TOOLBAR
@@ -286,11 +297,14 @@ void wxFrame::OnActivate(wxActivateEvent& event)
             break;
         }
     }
-    
-    if ( m_frameMenuBar != NULL )
-    {
-       m_frameMenuBar->MacInstallMenuBar() ;
-    }
+   */
+       wxSetFocusToChild(this, &m_winLastFocused);
+
+           if ( m_frameMenuBar != NULL )
+           {
+               m_frameMenuBar->MacInstallMenuBar() ;
+           }
+       }
 }
 
 void wxFrame::DoGetClientSize(int *x, int *y) const