+ else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame)))
+ {
+ // Trying toplevel frame membar
+ if (((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar())
+ ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar();
+ }
+ }
+}
+
+void wxFrame::DetachMenuBar()
+{
+ if ( m_frameMenuBar )
+ m_frameMenuBar->UnsetInvokingWindow();
+
+ wxFrameBase::DetachMenuBar();
+}
+
+void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
+{
+ wxFrame* tlf = wxDynamicCast( wxFindWinFromMacWindow( FrontNonFloatingWindow() ) , wxFrame );
+ bool makeCurrent = false;
+
+ // if this is already the current menubar or we are the frontmost window
+ if ( (tlf == this) || (m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar()) )
+ makeCurrent = true;
+ // or there is an app-level menubar like MDI
+ else if ( tlf && (tlf->GetMenuBar() == NULL) && (((wxFrame*)wxTheApp->GetTopWindow()) == this) )
+ makeCurrent = true;
+
+ wxFrameBase::AttachMenuBar( menuBar );
+
+ if (m_frameMenuBar)
+ {
+ m_frameMenuBar->SetInvokingWindow( this );
+ if (makeCurrent)
+ m_frameMenuBar->MacInstallMenuBar();