I'm making my first steps in learning wxWidgets. I learnt how to assign events to Menu Items or Buttons for example, because they do have IDs. But when I tried to assign an event to a Menu, I found it real difficult.
My aim was to asign one of those top Menus from the MenuBar a specific event, rather than them having a list of Menu Items. At first I didn't manage it, until I thought on using:
Connect(wxEVT_MENU_OPEN, wxCommandEventHandler(MainFrame::Config));
This worked fine, until I realized this now happens to all Menus! Which is evident though, as there is no place where I specified the Connect command to apply only for that Menu.
Any help here? I'd like that method to be executed just when a specific Menu is clicked, but not all! Thanks in beforehand.
Assuming you want MainFrame::Config to be called if the menu item created by
yourMenu->Append(SOME_ID, wxT("&Configuration"));
gets clicked, use
this->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::Config, this, SOME_ID);
if this is your mainframe.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.