diff --git a/docs/changes.txt b/docs/changes.txt index c2463065dd..dfd0250c52 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -174,6 +174,7 @@ wxGTK: - Fixed wxBitmapButton to use focus and hover bitmaps correctly. - Fixed race condition which could cause idle processing to stop without processing all pending events. +- wxAcceleratorTable now works with buttons too. wxMac: diff --git a/docs/latex/wx/accel.tex b/docs/latex/wx/accel.tex index a9f4804551..17d3b252b0 100644 --- a/docs/latex/wx/accel.tex +++ b/docs/latex/wx/accel.tex @@ -71,8 +71,7 @@ which modifier key is held down.} \section{\class{wxAcceleratorTable}}\label{wxacceleratortable} An accelerator table allows the application to specify a table of keyboard shortcuts for -menus or other commands. On Windows, menu or button commands are supported; on GTK, -only menu commands are supported. +menu or button commands. The object {\bf wxNullAcceleratorTable} is defined to be a table with no data, and is the initial accelerator table for a window. diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 150bdd00f7..9077c01f1d 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1051,8 +1051,18 @@ gtk_window_key_press_callback( GtkWidget *widget, int command = ancestor->GetAcceleratorTable()->GetCommand( event ); if (command != -1) { - wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); - ret = ancestor->GetEventHandler()->ProcessEvent( command_event ); + wxCommandEvent menu_event( wxEVT_COMMAND_MENU_SELECTED, command ); + ret = ancestor->GetEventHandler()->ProcessEvent( menu_event ); + + if ( !ret ) + { + // if the accelerator wasn't handled as menu event, try + // it as button click (for compatibility with other + // platforms): + wxCommandEvent button_event( wxEVT_COMMAND_BUTTON_CLICKED, command ); + ret = ancestor->GetEventHandler()->ProcessEvent( button_event ); + } + break; } if (ancestor->IsTopLevel())