X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2fc2d511d0f095ab5de3713cff6042832f886d15..eafde5c739891e7385b572be3253f7da7b072923:/src/cocoa/menuitem.mm diff --git a/src/cocoa/menuitem.mm b/src/cocoa/menuitem.mm index ba92f411a8..fdc0620a3e 100644 --- a/src/cocoa/menuitem.mm +++ b/src/cocoa/menuitem.mm @@ -28,6 +28,7 @@ #include "wx/cocoa/ObjcPose.h" #include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" #import #import @@ -47,27 +48,37 @@ } - (void)wxMenuItemAction: (id)sender; +- (BOOL)validateMenuItem: (id)menuItem; @end //interface wxNSMenuItemTarget @implementation wxNSMenuItemTarget : NSObject - (void)wxMenuItemAction: (id)sender { - wxLogDebug("wxMenuItemAction"); + wxLogTrace(wxTRACE_COCOA,wxT("wxMenuItemAction")); wxMenuItem *item = wxMenuItem::GetFromCocoa(sender); - wxCHECK_RET(item,"wxMenuItemAction received but no wxMenuItem exists!"); + wxCHECK_RET(item,wxT("wxMenuItemAction received but no wxMenuItem exists!")); wxMenu *menu = item->GetMenu(); - wxCHECK_RET(menu,"wxMenuItemAction received but wxMenuItem is not in a wxMenu"); + wxCHECK_RET(menu,wxT("wxMenuItemAction received but wxMenuItem is not in a wxMenu")); wxMenuBar *menubar = menu->GetMenuBar(); if(menubar) { wxFrame *frame = menubar->GetFrame(); - wxCHECK_RET(frame, "wxMenuBar MUST be attached to a wxFrame!"); - frame->Command(item->GetId()); + wxCHECK_RET(frame, wxT("wxMenuBar MUST be attached to a wxFrame!")); + frame->ProcessCommand(item->GetId()); } } +- (BOOL)validateMenuItem: (id)menuItem +{ + // TODO: Do wxWindows validation here and avoid sending during idle time + wxLogTrace(wxTRACE_COCOA,wxT("wxMenuItemAction")); + wxMenuItem *item = wxMenuItem::GetFromCocoa(menuItem); + wxCHECK_MSG(item,NO,wxT("validateMenuItem received but no wxMenuItem exists!")); + return item->IsEnabled(); +} + @end //implementation wxNSMenuItemTarget // ============================================================================ @@ -124,7 +135,7 @@ wxMenuItemCocoa::wxMenuItemCocoa(wxMenu *pParentMenu, : wxMenuItemBase(pParentMenu, itemid, strName, strHelp, kind, pSubMenu) { wxAutoNSAutoreleasePool pool; - NSString *menuTitle = [[NSString alloc] initWithCString: wxStripMenuCodes(strName).c_str()]; + NSString *menuTitle = wxInitNSStringWithWxString([NSString alloc],wxStripMenuCodes(strName)); m_cocoaNSMenuItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:@selector(wxMenuItemAction:) keyEquivalent:@""]; sm_cocoaHash.insert(wxMenuItemCocoaHash::value_type(m_cocoaNSMenuItem,this)); [m_cocoaNSMenuItem setTarget:sm_cocoaTarget]; @@ -157,7 +168,7 @@ void wxMenuItem::Enable(bool bDoEnable) void wxMenuItem::Check(bool bDoCheck) { - wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); + wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") ); wxMenuItemBase::Check(bDoCheck); }