wxMenuBar * menubar = m_frame->GetMenuBar();
wxMenu * menu = menubar->GetMenu(1);
wxInt32 menuId = menu->FindItem(wxT("MENU"));
wxMenuItem * menuItem = menu->FindItem(menuId);
wxMenu * steps = menuItem->GetSubMenu();
steps->Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(Class::OnMENU), NULL, this);
This is the code but when I click on the menu, OnMENU is not triggered. Is this right?
AFAIK command events, such as menu events, are sent to the parent window, which in this case is m_frame
. You need to call Connect()
on m_frame
, not on the menu (item).