]> git.saurik.com Git - wxWidgets.git/commitdiff
support accelerators for buttons too (slightly modified patch 1549012)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Apr 2007 17:05:00 +0000 (17:05 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Apr 2007 17:05:00 +0000 (17:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/accel.tex
src/mac/carbon/app.cpp

index 5d005bedf40b3b40b69e6e91fb791a3c6baf1ef5..564cb531745a2a9c57bcec7af6769d58844b46e9 100644 (file)
@@ -116,6 +116,7 @@ wxGTK:
 wxMac:
 
 - Fix duplicate (empty) help menu in non-English programs (Andreas Jacobs)
+- Allow accelerators to be used with buttons too (Ryan Wilcox)
 
 wxMSW:
 
index a9f4804551edc657a08e7011a29a322d2f40ed27..0ee4778c9c5ad16896b0b489c19cb97efa746237 100644 (file)
@@ -71,7 +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,
+menus or other commands. On Windows and Mac OS X, menu or button commands are supported; on GTK,
 only menu commands are supported.
 
 The object {\bf wxNullAcceleratorTable} is defined to be a table with no data, and is the
index e04d27946cc7a21ef06f892782fcb1f8ce409e87..4f1c4734653230995412da2a80d27b63c95ca0e7 100644 (file)
@@ -1540,8 +1540,18 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi
             int command = ancestor->GetAcceleratorTable()->GetCommand( event );
             if (command != -1)
             {
+                wxEvtHandler * const handler = ancestor->GetEventHandler();
+
                 wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
-                handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
+                handled = handler->ProcessEvent( command_event );
+
+                if ( !handled )
+                {
+                    // accelerators can also be used with buttons, try them too
+                    command_event.SetEventType(wxEVT_COMMAND_BUTTON_CLICKED);
+                    handled = handler->ProcessEvent( command_event );
+                }
+
                 break;
             }