X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9a4f2295344414e2ee4e3ec27fa5292918dff27..7c60222510bc5e197b12f153c4bf05db66cb0f4a:/src/osx/cocoa/menu.mm diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 346b992bf3..70e4fc3aaf 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -18,16 +18,16 @@ #include "wx/wxprec.h" -#include "wx/menu.h" - #ifndef WX_PRECOMP - #include "wx/log.h" - #include "wx/app.h" - #include "wx/utils.h" - #include "wx/frame.h" - #include "wx/menuitem.h" +#include "wx/log.h" +#include "wx/app.h" +#include "wx/utils.h" +#include "wx/frame.h" +#include "wx/menuitem.h" #endif +#include "wx/menu.h" + #include "wx/osx/private.h" // other standard headers @@ -38,7 +38,7 @@ - (id) initWithTitle:(NSString*) title { - [super initWithTitle:title]; + self = [super initWithTitle:title]; impl = NULL; return self; } @@ -55,11 +55,19 @@ @end +// this is more compatible, as it is also called for command-key shortcuts +// and under 10.4, we are not getting a 'close' event however... +#define wxOSX_USE_NEEDSUPDATE_HOOK 1 + @interface wxNSMenuController : NSObject wxOSX_10_6_AND_LATER() { } +#if wxOSX_USE_NEEDSUPDATE_HOOK +- (void)menuNeedsUpdate:(NSMenu*)smenu; +#else - (void)menuWillOpen:(NSMenu *)menu; +#endif - (void)menuDidClose:(NSMenu *)menu; - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item; @@ -69,10 +77,23 @@ - (id) init { - [super init]; + self = [super init]; return self; } +#if wxOSX_USE_NEEDSUPDATE_HOOK +- (void)menuNeedsUpdate:(NSMenu*)smenu +{ + wxNSMenu* menu = (wxNSMenu*) smenu; + wxMenuImpl* menuimpl = [menu implementation]; + if ( menuimpl ) + { + wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer(); + if ( wxpeer ) + wxpeer->HandleMenuOpened(); + } +} +#else - (void)menuWillOpen:(NSMenu *)smenu { wxNSMenu* menu = (wxNSMenu*) smenu; @@ -84,6 +105,7 @@ wxpeer->HandleMenuOpened(); } } +#endif - (void)menuDidClose:(NSMenu *)smenu { @@ -144,7 +166,7 @@ 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) + // make sure a call of SetSubMenu is also reflected (occurring after Create) // update the native menu item accordingly if ( pItem->IsSubMenu() )