wxWidgets 快捷键无法使用

wxWidgets 快捷键无法正常使用

在maniframe中定义了快捷键:
```c++
#if _WIN32
    // This is needed on Windows to fake the CTRL+# of the window menu when using the numpad
    wxAcceleratorEntry entries[8];
    entries[0].Set(wxACCEL_CTRL, WXK_NUMPAD1, wxID_HIGHEST + 1);
    entries[1].Set(wxACCEL_CTRL, WXK_NUMPAD2, wxID_HIGHEST + 2);
    entries[2].Set(wxACCEL_CTRL, WXK_NUMPAD3, wxID_HIGHEST + 3);
    entries[3].Set(wxACCEL_CTRL, WXK_NUMPAD4, wxID_HIGHEST + 4);
    entries[4].Set(wxACCEL_CTRL, WXK_NUMPAD5, wxID_HIGHEST + 5);
    entries[5].Set(wxACCEL_CTRL, WXK_NUMPAD6, wxID_HIGHEST + 6);
    entries[6].Set(wxACCEL_CTRL, (int) 'O', wxID_HIGHEST + 7);
    entries[7].Set(wxACCEL_CTRL, (int) 'N', wxID_HIGHEST + 8);
    wxAcceleratorTable accel(8, entries);
    SetAcceleratorTable(accel);
#endif // _WIN32

append_menu_item(
            fileMenu,wxID_HIGHEST + 8, _L("&New Project") + "\tCtrl+N", _L("Start a new project "),
            [this](wxCommandEvent&) { if (m_plater) m_plater->new_project(); }, "", nullptr,
            [this](){return m_plater != nullptr && can_start_new_project(); }, this);


wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
    std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler,
    std::function<bool()> const cb_condition, wxWindow* parent, int insert_pos/* = wxNOT_FOUND*/)
{
    if (id == wxID_ANY)
        id = wxNewId();

    auto *item = new wxMenuItem(menu, id, string, description);

    if (icon && icon->IsOk()) {
        item->SetBitmap(*icon);
    }
    if (insert_pos == wxNOT_FOUND)
        menu->Append(item);
    else
        menu->Insert(insert_pos, item);

#ifdef __WXMSW__
    if (event_handler != nullptr && event_handler != menu)
        event_handler->Bind(wxEVT_MENU, cb, id);
    else
#endif // __WXMSW__
        menu->Bind(wxEVT_MENU, cb, id);

    /*auto _event = wxMenuEvent(wxEVT_ENTER_WINDOW, id, menu);
    wxPostEvent(menu, _event);
    auto _event_2 = wxMenuEvent(wxEVT_LEAVE_WINDOW, id, menu);
    wxPostEvent(menu, _event_2);
    menu->Bind(
        wxEVT_ENTER_WINDOW,
        [item](wxMouseEvent &) {
            item->SetBackgroundColour(wxColour(255, 0, 0));
        },
        id);
    menu->Bind(
        wxEVT_LEAVE_WINDOW,
        [item](wxMouseEvent &) {
            item->SetBackgroundColour(wxColour(255, 255,255));
        },
        id);*/


    if (parent) {
        parent->Bind(wxEVT_UPDATE_UI, [cb_condition, item, parent](wxUpdateUIEvent& evt) {
                enable_menu_item(evt, cb_condition, item, parent);
            },id);
    }

    return item;
}

使用的是自定义的对象开启,没有使用SetMenuBar().
软件主界面使用布局加入自定义对象,然后再自定义对象里面弹窗上下文菜单。popupmenu.

this->PopupMenu(m_edit_menu, wxPoint(m_btEdit->GetPosition().x, this->GetSize().GetHeight()));

软件启动后,无法在主页面使用快捷键


已解决。
目前看起来就popupMenu无法获取到焦点。所以需要在主窗口捕获wxmenu事件。wxmenuItem的id绑定好快捷键, 然后主窗口根据事件id来处理事件。