'CallMenu (_T ("/Help/Tips"))' ...
Did you consider the shortcuts? Namely:
CallMenu(_T("/&Help/&Tips"))
(Just a wild guess - I have no access to c::B at the moment...)
I try CallMenu(_T("/&Help/&Tips"))
but no !
I try CallMenu(_T("/&Help/Tips"))
no ...
Works fine here with
CallMenu(_T("/Help/Tips"))
with english locale, and
CallMenu(_T("/Hilfe/Tips"))
with my (default) german locale.
If you have switched internationalization on, some of the strings will be localized (like "Help", "Close", "open" etc.).
You have to use the exact spelling of the menu-entries.
/**** Translation by GOOGLE ****/
Thank you for your answers.
I wrote a 'menu.script'
// menu.script
function main() {
// with english locale
CallMenu(_T("/Help/Tips")) ;
// with my french locale.
CallMenu(_T("/Aide/Astuces")) ;
// with german locale.
CallMenu(_T("/Hilfe/Tips")) ;
}
called from the command line console script by "main () '
Then I changed 'codeblocks-10.05-release\src\sdk\scripting\bindings\sc_globals.cpp' (with wxWidgets 2.8.11)
// locate and call a menu from string (e.g. "/Valgrind/Run Valgrind::MemCheck")
void CallMenu(const wxString& menuPath)
{
// -> LETARTARE
gWarningLog (_T("'CallMenu(") + menuPath + _T(")'"));
// <-
// this code is partially based on MenuItemsManager::CreateFromString()
wxMenuBar* mbar = Manager::Get()->GetAppFrame()->GetMenuBar();
wxMenu* menu = 0;
size_t pos = 0;
while (true)
{
// ignore consecutive slashes
while (pos < menuPath.Length() && menuPath.GetChar(pos) == _T('/'))
{
++pos;
}
// find next slash
size_t nextPos = pos;
while (nextPos < menuPath.Length() && menuPath.GetChar(++nextPos) != _T('/'))
;
wxString current = menuPath.Mid(pos, nextPos - pos);
if (current.IsEmpty())
break;
bool isLast = nextPos >= menuPath.Length();
// current holds the current search string
if (!menu) // no menu yet? look in menubar
{
int menuPos = mbar->FindMenu(current);
if (menuPos == wxNOT_FOUND)
break; // failed
else
menu = mbar->GetMenu(menuPos);
}
else
{
if (isLast)
{
int id = menu->FindItem(current);
if (id != wxNOT_FOUND)
{
// --> begin modification : LETARTARE
bool ret;
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, id);
#if wxCHECK_VERSION(2, 9, 0)
ret = mbar->GetEventHandler()->ProcessEvent(evt);
if (ret)
gWarningLog (_T("2.9.0 :Process entries '") + menuPath + _T("'") );
else
gErrorLog(_T("2.9.0 : error process entries"));
#else
ret = mbar->ProcessEvent(evt);
if (ret)
gWarningLog (_T(" Process entries '") + menuPath + _T("'"));
else
gErrorLog(_T(" error process entries"));
// <-- end
#endif
// done
}
break;
}
int existing = menu->FindItem(current);
if (existing != wxNOT_FOUND)
menu = menu->GetMenuItems()[existing]->GetSubMenu();
else
break; // failed
}
pos = nextPos; // prepare for next loop
}
}
Results of the script in the console log
1 - compiled with the sources (French version)
'CallMenu(/Help/Tips)'
'CallMenu(/Aide/Astuces)'
error process entries
'CallMenu(/Hilfe/Tips)'
2 - compiled with the sources (English version)
'CallMenu(/Help/Tips)'
error process entries
'CallMenu(/Aide/Astuces)'
'CallMenu(/Hilfe/Tips)'
3 - from version installed (10.5 rev 6283, unicode wxWidgets 8.2.10) French version
'CallMenu(/Help/Tips)'
'CallMenu(/Aide/Astuces)'
error process entries
'CallMenu(/Hilfe/Tips)'
It seems that 'wxMenuBar-> processEvents (evt)' does not give the desired result.
After that, I do not know ... Maybe a version problem of 'wxWidgets'?