]> git.saurik.com Git - wxWidgets.git/commitdiff
made wxAcceleratorTable work with buttons in wxGTK too
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 18 Mar 2008 16:21:15 +0000 (16:21 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 18 Mar 2008 16:21:15 +0000 (16:21 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52615 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

interface/accel.h
src/gtk/window.cpp

index 87a820b06babca2a2a25a9f6a83405f4aaa8db10..39b08f42977f4e860da17df3801b5805e9c453e6 100644 (file)
@@ -96,8 +96,7 @@ public:
     @wxheader{accel.h}
 
     An accelerator table allows the application to specify a table of keyboard
-    shortcuts for menus or other commands. On Windows and Mac OS X, menu or button
-    commands are supported; on GTK, only menu commands are supported.
+    shortcuts for menu or button commands.
 
     The object ::wxNullAcceleratorTable is defined to be a table with no data, and
     is the initial accelerator table for a window.
index 2ea22d82b23b2b0e209763f410cde89309db0f18..67635d23f205adeda7275ca81db49b0dd29e1b2c 100644 (file)
@@ -869,8 +869,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->HandleWindowEvent( command_event );
+                wxCommandEvent menu_event( wxEVT_COMMAND_MENU_SELECTED, command );
+                ret = ancestor->HandleWindowEvent( 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->HandleWindowEvent( button_event );
+                }
+
                 break;
             }
             if (ancestor->IsTopLevel())