"Fix" issues with hotkeys not working with wxGTK

GTK accelerators silently swallow the keypresses when the menu item is
disabled, so disable accelerators completely and just use our hotkey system.

Closes #1314.

Originally committed to SVN as r6673.
This commit is contained in:
Thomas Goyne 2012-04-07 01:06:34 +00:00
parent db69fdbbcd
commit c614980dca
1 changed files with 19 additions and 1 deletions

View File

@ -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) {