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
This commit is contained in:
Vadim Zeitlin
2007-04-07 17:05:00 +00:00
parent 947848a1dd
commit 7816e624f3
3 changed files with 13 additions and 2 deletions

View 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:

View 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

View 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;
}