- menu.Append(Menu_Help_About, "&About");
- menu.Append(Menu_Popup_Submenu, "Submenu", CreateDummyMenu());
- menu.Append(Menu_Popup_ToBeDeleted, "To be deleted");
- menu.Append(Menu_Popup_ToBeChecked, "To be checked", "", TRUE);
- menu.Append(Menu_Popup_ToBeGreyed, "To be greyed");
+ wxString label = wxGetTextFromUser
+ (
+ _T("Enter label to search for: "),
+ _T("Find menu item"),
+ _T(""),
+ this
+ );
+
+ if ( !label.empty() )
+ {
+ size_t menuindex = 0;
+ int index = wxNOT_FOUND;
+
+ for (menuindex = 0; (menuindex < count) && (index == wxNOT_FOUND); ++menuindex)
+ {
+ index = mbar->FindMenuItem(mbar->GetMenu(menuindex)->GetTitle(), label);
+ }
+ if (index == wxNOT_FOUND)
+ {
+ wxLogWarning(wxT("No menu item with label '%s'"), label.c_str());
+ }
+ else
+ {
+ wxLogMessage(wxT("Menu item %d in menu %lu has label '%s'"),
+ index, (unsigned long)menuindex, label.c_str());
+ }
+ }
+}
+
+void MyFrame::ShowContextMenu(const wxPoint& pos)
+{
+ wxMenu menu(_T("Test popup"));
+
+ menu.Append(Menu_Help_About, _T("&About"));
+ menu.Append(Menu_Popup_Submenu, _T("&Submenu"), CreateDummyMenu(NULL));
+ menu.Append(Menu_Popup_ToBeDeleted, _T("To be &deleted"));
+ menu.Append(Menu_Popup_ToBeChecked, _T("To be &checked"), _T(""), TRUE);
+ menu.Append(Menu_Popup_ToBeGreyed, _T("To be &greyed"),
+ _T("This menu item should be initially greyed out"));