X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/41b78190adf985fa6e91a34aba76b1693a8ffc72..245f35816d761212279e8cf223475efb7a367553:/src/common/menucmn.cpp diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 5b224a1ddf..7ce3d36fde 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -81,6 +81,15 @@ wxMenuItemBase::~wxMenuItemBase() #if wxUSE_ACCEL +static inline bool CompareAccelString(const wxString& str, const wxChar *accel) +{ +#if wxUSE_INTL + return str == accel || str == wxGetTranslation(accel); +#else + return str == accel; +#endif +} + // return wxAcceleratorEntry for the given menu string or NULL if none // specified wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) @@ -94,11 +103,11 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) wxString current; for ( size_t n = (size_t)posTab + 1; n < label.Len(); n++ ) { if ( (label[n] == '+') || (label[n] == '-') ) { - if ( current == _("ctrl") ) + if ( CompareAccelString(current, wxTRANSLATE("ctrl")) ) accelFlags |= wxACCEL_CTRL; - else if ( current == _("alt") ) + else if ( CompareAccelString(current, wxTRANSLATE("alt")) ) accelFlags |= wxACCEL_ALT; - else if ( current == _("shift") ) + else if ( CompareAccelString(current, wxTRANSLATE("shift")) ) accelFlags |= wxACCEL_SHIFT; else { // we may have "Ctrl-+", for example, but we still want to @@ -183,7 +192,7 @@ wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) keyCode = WXK_SPACE; else if ( current == wxT("TAB") ) keyCode = WXK_TAB; - else if ( current == wxT("ESC") || current == wxT("ESCAPE") ) { + else if ( current == wxT("ESC") || current == wxT("ESCAPE") ) keyCode = WXK_ESCAPE; else { @@ -310,6 +319,7 @@ bool wxMenuBase::DoAppend(wxMenuItem *item) wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Append()") ); m_items.Append(item); + item->SetMenu((wxMenu*)this); if ( item->IsSubMenu() ) { AddSubMenu(item->GetSubMenu()); @@ -343,6 +353,7 @@ bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item) wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") ); m_items.Insert(node, item); + item->SetMenu((wxMenu*)this); if ( item->IsSubMenu() ) { AddSubMenu(item->GetSubMenu()); @@ -371,6 +382,7 @@ wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item) m_items.DeleteNode(node); // item isn't attached to anything any more + item->SetMenu((wxMenu *)NULL); wxMenu *submenu = item->GetSubMenu(); if ( submenu ) {