X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9a4f2295344414e2ee4e3ec27fa5292918dff27..0afeb753e0a6a3fdba290bf3612bb2f012d44d95:/src/osx/cocoa/menuitem.mm diff --git a/src/osx/cocoa/menuitem.mm b/src/osx/cocoa/menuitem.mm index c0e1b058f6..05179eca9e 100644 --- a/src/osx/cocoa/menuitem.mm +++ b/src/osx/cocoa/menuitem.mm @@ -33,8 +33,11 @@ struct Mapping Mapping sActionToWXMapping[] = { +// as we don't have NSUndoManager support we must not use the native actions +#if 0 { wxID_UNDO, @selector(undo:) }, { wxID_REDO, @selector(redo:) }, +#endif { wxID_CUT, @selector(cut:) }, { wxID_COPY, @selector(copy:) }, { wxID_PASTE, @selector(paste:) }, @@ -74,8 +77,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 +103,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 +127,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 ) @@ -127,6 +140,9 @@ void wxMacCocoaMenuItemSetAccelerator( NSMenuItem* menuItem, wxAcceleratorEntry* if (entry->GetFlags() & wxACCEL_CTRL) modifiers |= NSCommandKeyMask; + if (entry->GetFlags() & wxACCEL_RAW_CTRL) + modifiers |= NSControlKeyMask; + if (entry->GetFlags() & wxACCEL_ALT) modifiers |= NSAlternateKeyMask ; @@ -256,9 +272,7 @@ public : wxCFStringRef cfText(text); [m_osxMenuItem setTitle:cfText.AsNSString()]; - if ( entry ) - wxMacCocoaMenuItemSetAccelerator( m_osxMenuItem, entry ); - + wxMacCocoaMenuItemSetAccelerator( m_osxMenuItem, entry ); } bool DoDefault(); @@ -297,6 +311,10 @@ bool wxMenuItemCocoaImpl::DoDefault() [theNSApplication unhideAllApplications:nil]; handled=true; } + else if (menuid == wxApp::s_macExitMenuItemId) + { + wxTheApp->ExitMainLoop(); + } return handled; } @@ -320,7 +338,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 +360,7 @@ wxMenuItemImpl* wxMenuItemImpl::Create( wxMenuItem* peer, wxMenu *pParentMenu, } else { - if ( entry ) - wxMacCocoaMenuItemSetAccelerator( menuitem, entry ); + wxMacCocoaMenuItemSetAccelerator( menuitem, entry ); } item = menuitem; }