X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/670f9935630beb2123a5ca62894ae92a3f0efa4f..ff42758536f8d573409bf6c35528497ba36b4d0e:/src/mac/carbon/menuitem.cpp diff --git a/src/mac/carbon/menuitem.cpp b/src/mac/carbon/menuitem.cpp index 44b80b1319..7d6dc48db1 100644 --- a/src/mac/carbon/menuitem.cpp +++ b/src/mac/carbon/menuitem.cpp @@ -12,13 +12,13 @@ #include "wx/wxprec.h" #include "wx/menuitem.h" +#include "wx/stockitem.h" #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/menu.h" #endif // WX_PRECOMP -#include "wx/menu.h" - #include "wx/mac/uma.h" IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) @@ -121,7 +121,7 @@ void wxMenuItem::UpdateItemStatus() ::SetItemMark( mhandle , index , 0 ) ; // no mark UMASetMenuItemText( mhandle , index , wxStripMenuCodes(m_text) , wxFont::GetDefaultEncoding() ) ; - wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; + wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ; UMASetMenuItemShortcut( mhandle , index , entry ) ; delete entry ; } @@ -137,8 +137,15 @@ void wxMenuItem::UpdateItemText() if (mhandle == NULL || index == 0) return ; - UMASetMenuItemText( mhandle , index , wxStripMenuCodes(m_text) , wxFont::GetDefaultEncoding() ) ; - wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; + wxString text = m_text; + if (text.IsEmpty() && !IsSeparator()) + { + wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?")); + text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC); + } + + UMASetMenuItemText( mhandle , index , wxStripMenuCodes(text) , wxFont::GetDefaultEncoding() ) ; + wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( text ) ; UMASetMenuItemShortcut( mhandle , index , entry ) ; delete entry ; }