I’ve got menu in which i need to place dynamically few items( i don’t know how many until app launch;-). It’s not problem to put item in menu, and connect it`s event to some function. But i need to check which item from menu was chosen. Can i send int or wxString with click at menu item? How?
wxMenu *MyTaskBarIcon::CreatePopupMenu(){
wxMenu *menu = new wxMenu;
menu->Append(ITEM1, _("Item1"));
Connect(ITEM1,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyTaskBarIcon::Check));
menu->Append(ITEM2, _("Item2"));
Connect(ITEM2,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyTaskBarIcon::CheckMenu));
menu->AppendSeparator();
menu->Append(PU_EXIT, wxT("E&xit"));
}
void MyTaskBarIcon::Check(wxCommandEvent& event){
//How to send int/wxString to this method?
}
Any ideas?
How about assigning a range of IDs to this menu? Then when you append the items to the menu, you can increment the ID each time, so each item gets a unique ID. Then you create an event handler for each ID, and call a common handler with the ID as a parameter. Or, you could use
If the strings vary at runtime then you will have to store the strings in an array, and recall them from there using the ID minus the start of the range ID as the index into the array.