X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9c894932284cac53d9cd8d8b2f16308bc65f44d6..f239a20092359e3c914adb79bd39f3f5d2b2e06f:/src/osx/cocoa/menuitem.mm diff --git a/src/osx/cocoa/menuitem.mm b/src/osx/cocoa/menuitem.mm index ee55d575df..543b64f321 100644 --- a/src/osx/cocoa/menuitem.mm +++ b/src/osx/cocoa/menuitem.mm @@ -4,7 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: menuitem.cpp 54129 2008-06-11 19:30:52Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -74,8 +74,8 @@ SEL wxOSXGetSelectorFromID(int menuId ) - (id) initWithTitle:(NSString *)aString action:(SEL)aSelector keyEquivalent:(NSString *)charCode { - [super initWithTitle:aString action:aSelector keyEquivalent:charCode]; - return self; + self = [super initWithTitle:aString action:aSelector keyEquivalent:charCode]; + return self; } - (void) clickedAction: (id) sender @@ -100,8 +100,12 @@ SEL wxOSXGetSelectorFromID(int menuId ) wxUnusedVar(menuItem); if( impl ) { - if ( impl->GetWXPeer()->GetMenu()->HandleCommandUpdateStatus(impl->GetWXPeer()) ) - return impl->GetWXPeer()->IsEnabled(); + wxMenuItem* wxmenuitem = impl->GetWXPeer(); + if ( wxmenuitem ) + { + wxmenuitem->GetMenu()->HandleCommandUpdateStatus(wxmenuitem); + return wxmenuitem->IsEnabled(); + } } return YES ; } @@ -120,6 +124,12 @@ SEL wxOSXGetSelectorFromID(int menuId ) void wxMacCocoaMenuItemSetAccelerator( NSMenuItem* menuItem, wxAcceleratorEntry* entry ) { + if ( entry == NULL ) + { + [menuItem setKeyEquivalent:@""]; + return; + } + unsigned int modifiers = 0 ; int key = entry->GetKeyCode() ; if ( key ) @@ -256,9 +266,7 @@ public : wxCFStringRef cfText(text); [m_osxMenuItem setTitle:cfText.AsNSString()]; - if ( entry ) - wxMacCocoaMenuItemSetAccelerator( m_osxMenuItem, entry ); - + wxMacCocoaMenuItemSetAccelerator( m_osxMenuItem, entry ); } bool DoDefault(); @@ -320,7 +328,7 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, wxCFStringRef cfText(text); SEL selector = nil; bool targetSelf = false; - if ( ! pParentMenu->GetNoEventsMode() && pSubMenu == NULL ) + if ( (pParentMenu == NULL || !pParentMenu->GetNoEventsMode()) && pSubMenu == NULL ) { selector = wxOSXGetSelectorFromID(menuid); @@ -342,8 +350,7 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, } else { - if ( entry ) - wxMacCocoaMenuItemSetAccelerator( menuitem, entry ); + wxMacCocoaMenuItemSetAccelerator( menuitem, entry ); } item = menuitem; }