diff --git a/aegisub/src/menu.cpp b/aegisub/src/menu.cpp index 86134dba2..a8b1fbb03 100644 --- a/aegisub/src/menu.cpp +++ b/aegisub/src/menu.cpp @@ -441,7 +441,25 @@ namespace menu { window->Bind(wxEVT_MENU_OPEN, &CommandManager::OnMenuOpen, &menu->cm); window->Bind(wxEVT_COMMAND_MENU_SELECTED, &CommandManager::OnMenuClick, &menu->cm); - window->SetMenuBar(menu.release()); + window->SetMenuBar(menu.get()); + +#ifdef __WXGTK__ + // GTK silently swallows keypresses for accelerators whose associated + // menu items are disabled. As we don't update the menu until it's + // opened, this means that conditional hotkeys don't work if the menu + // hasn't been opened since they became valid. + // + // To work around this, we completely disable accelerators from menu + // item. wxGTK doesn't expose any way to do this other that at wx + // compile time (SetAcceleratorTable is a no-op), so have some fun with + // the implementation details of undocumented methods. Detaching via + // wxMenuBar::Detach removes the accelerator table, and then + // wxMenuBarBase::Attch is used to avoid readding it. + menu->Detach(); + menu->wxMenuBarBase::Attach(window); +#endif + + menu.release(); } wxMenu *GetMenu(std::string const& name, agi::Context *c) {