X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/030495ecf11a16c27e711f0d812226d6b940d42b..60372b0d54379701d62edf5595a7dc25c48330e1:/src/osx/cocoa/menu.mm?ds=sidebyside diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 39ebcf6aca..22fabe5344 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -4,7 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: menu.cpp 54129 2008-06-11 19:30:52Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,9 +36,9 @@ @implementation wxNSMenu -- (id) init +- (id) initWithTitle:(NSString*) title { - [super init]; + self = [super initWithTitle:title]; impl = NULL; return self; } @@ -69,7 +69,7 @@ - (id) init { - [super init]; + self = [super init]; return self; } @@ -143,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 )