X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/43524b1583cbe798351fef03242f0990e1cfddc2..80a779275ae04443c568dca919adb26cf6f5002c:/src/mac/carbon/menuitem.cpp diff --git a/src/mac/carbon/menuitem.cpp b/src/mac/carbon/menuitem.cpp index 6065ff1b92..7d6dc48db1 100644 --- a/src/mac/carbon/menuitem.cpp +++ b/src/mac/carbon/menuitem.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: menuitem.cpp +// Name: src/mac/carbon/menuitem.cpp // Purpose: wxMenuItem implementation // Author: Stefan Csomor // Modified by: @@ -11,9 +11,13 @@ #include "wx/wxprec.h" -#include "wx/app.h" -#include "wx/menu.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/mac/uma.h" @@ -117,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 ; } @@ -133,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 ; }