From: Gilles Depeyrot Date: Sat, 14 Dec 2002 21:44:48 +0000 (+0000) Subject: fix FindMenu broken by implementation of double ampersands in menu and menu X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7cf4f7e21fc8b72498097e54c47c623331431f2c fix FindMenu broken by implementation of double ampersands in menu and menu item titles (finding "&File" was no longer working) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18237 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 3701f416ee..01e00de077 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -591,6 +591,9 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const continue; } + // don't remove ampersands '&' since if we have them in the menu title + // it means that they were doubled to indicate "&" instead of accelerator + label += *pc; } @@ -778,7 +781,7 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) for ( const wxChar *pc = text.c_str(); *pc; pc++ ) { - if ( *pc == wxT('_') ) + if ( *pc == wxT('_') ) { // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx" pc++; @@ -796,9 +799,15 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) } #endif + if ( (*pc == wxT('&')) && (*(pc+1) != wxT('&')) ) + { + // wxMSW escapes "&" + // "&" is doubled to indicate "&" instead of accelerator + continue; + } + label += *pc; } - return label; } @@ -971,6 +980,9 @@ wxString wxMenuItem::GetFactoryPath() const continue; } + // don't remove ampersands '&' since if we have them in the menu item title + // it means that they were doubled to indicate "&" instead of accelerator + path += *pc; } diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 3701f416ee..01e00de077 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -591,6 +591,9 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const continue; } + // don't remove ampersands '&' since if we have them in the menu title + // it means that they were doubled to indicate "&" instead of accelerator + label += *pc; } @@ -778,7 +781,7 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) for ( const wxChar *pc = text.c_str(); *pc; pc++ ) { - if ( *pc == wxT('_') ) + if ( *pc == wxT('_') ) { // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx" pc++; @@ -796,9 +799,15 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) } #endif + if ( (*pc == wxT('&')) && (*(pc+1) != wxT('&')) ) + { + // wxMSW escapes "&" + // "&" is doubled to indicate "&" instead of accelerator + continue; + } + label += *pc; } - return label; } @@ -971,6 +980,9 @@ wxString wxMenuItem::GetFactoryPath() const continue; } + // don't remove ampersands '&' since if we have them in the menu item title + // it means that they were doubled to indicate "&" instead of accelerator + path += *pc; }