From 7816e624f3cc9041de71b4acfe183976624ff833 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 7 Apr 2007 17:05:00 +0000 Subject: [PATCH] support accelerators for buttons too (slightly modified patch 1549012) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/accel.tex | 2 +- src/mac/carbon/app.cpp | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 5d005bedf4..564cb53174 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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: diff --git a/docs/latex/wx/accel.tex b/docs/latex/wx/accel.tex index a9f4804551..0ee4778c9c 100644 --- a/docs/latex/wx/accel.tex +++ b/docs/latex/wx/accel.tex @@ -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 diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index e04d27946c..4f1c473465 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -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; } -- 2.45.2