Ticket #12917 (closed defect: fixed)
[wxOSX_COCOA] Key&board accelerators for button labels
| Reported by: | joostn | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | wxOSX-Cocoa | Version: | 2.9-svn |
| Keywords: | wxbutton button shortcut accelerator | Cc: | joost@… |
| Blocked By: | Patch: | yes | |
| Blocking: |
Description
Sample app:
#include "wx/wx.h"
class MyFrame : public wxFrame
{
DECLARE_CLASS( MyFrame )
DECLARE_EVENT_TABLE()
public:
MyFrame()
: wxFrame(NULL,wxID_ANY,wxT("Frame"))
{
wxButton *btn1=new wxButton(this,1100,wxT("Button &A"),wxPoint(0,10));
wxButton *btn2=new wxButton(this,1101,wxT("Button &B"),wxPoint(0,100));
}
void OnButtonAClick(wxCommandEvent &event)
{
wxMessageBox(wxT("A"));
}
void OnButtonBClick(wxCommandEvent &event)
{
wxMessageBox(wxT("B"));
}
};
IMPLEMENT_CLASS( MyFrame, wxFrame )
BEGIN_EVENT_TABLE( MyFrame, wxFrame )
EVT_BUTTON( 1100, MyFrame::OnButtonAClick )
EVT_BUTTON( 1101, MyFrame::OnButtonBClick )
END_EVENT_TABLE()
class MyApp : public wxApp
{
public:
bool OnInit()
{
wxApp::OnInit();
MyFrame *frame=new MyFrame();
frame->Show();
return true;
}
};
DECLARE_APP(MyApp)
IMPLEMENT_APP(MyApp)
Pressing Cmd+A should invoke button A and Cmd+B should invoke button B, just like the Alt shortcuts under windows. This is accomplished by the attached patch.
Keyboard shortcut is ignored if the button is the default button, since I haven't found a way to attach two keys to the same button.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

