X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c17cb8c2c4e8dc53ce4a8d2da3dab56e804efa9..cbe067603829728da8852282e895f25b2bccf732:/src/osx/cocoa/menu.mm diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 34ea162c4d..ea02cf9f2b 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -55,10 +55,7 @@ @end -@interface wxNSMenuController : NSObject -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 - -#endif +@interface wxNSMenuController : NSObject wxOSX_10_6_AND_LATER() { } @@ -146,10 +143,25 @@ public : virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) { + NSMenuItem* nsmenuitem = (NSMenuItem*) pItem->GetPeer()->GetHMenuItem(); + // make sure a call of SetSubMenu is also reflected (occuring after Create) + // update the native menu item accordingly + + if ( pItem->IsSubMenu() ) + { + wxMenu* wxsubmenu = pItem->GetSubMenu(); + WXHMENU nssubmenu = wxsubmenu->GetHMenu(); + if ( [nsmenuitem submenu] != nssubmenu ) + { + wxsubmenu->GetPeer()->SetTitle( pItem->GetItemLabelText() ); + [nsmenuitem setSubmenu:nssubmenu]; + } + } + if ( pos == (size_t) -1 ) - [m_osxMenu addItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem() ]; + [m_osxMenu addItem:nsmenuitem ]; else - [m_osxMenu insertItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem() atIndex:pos]; + [m_osxMenu insertItem:nsmenuitem atIndex:pos]; } virtual void Remove( wxMenuItem *pItem )