[wxGTK 2.8.0] accelerators not working
notnot
notnot at xs4all.nl
Fri Feb 23 12:23:51 PST 2007
Hello all,
I'm having troubles getting accelerators to work, via SetAcceleratorTable().
See this minimal program that won't function properly on wxGTK, but works
fine with wxMac and wxMSW. (Note that on wxMSW, the accelerator keys are
case sensitive, on wxMac they are not).
Could it be that I misconfigured wxGTK while installing it? I have
configured wxGTK
with --with-opengl --enable-shared --disable-no_rtti --disable-no_exceptions.
Does wxWidgets write an installation log file that I could check to spot any
differences between my wxGTK/wxMac/wxMSW installations?
I have googled and searched the wxWidget archives, and learned quite a
bit, but
apparently not enough to solve my problem...
**************************************************************************************
#include <cstdio>
#include "wx/wx.h"
//menu item id's
enum
{
ID_Exit = wxID_EXIT,
ID_About = wxID_ABOUT,
ID_Test = wxID_HIGHEST + 1
};
////////////////////////////////////////////////////////////////////////////////
//class definitions
////////////////////////////////////////////////////////////////////////////////
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
//event handlers
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnTest(wxCommandEvent& event);
private:
DECLARE_EVENT_TABLE()
};
////////////////////////////////////////////////////////////////////////////////
//class implementations
////////////////////////////////////////////////////////////////////////////////
bool MyApp::
OnInit()
{
if (!wxApp::OnInit()) return false;
MyFrame *frame = new MyFrame(wxString(L"accelerators"),
wxPoint(100, 100), wxSize(256, 256));
frame->Show(true);
SetTopWindow(frame);
return true;
}
MyFrame::
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(0, wxID_ANY, title, pos, size)
{
//accelerators
#ifdef wxUSE_ACCEL
wxMessageBox(L"wxUSE_ACCEL defined", L"MyFrame::MyFrame()", wxOK, this);
wxAcceleratorEntry entries[3];
entries[0].Set(wxACCEL_NORMAL, (int)'E', ID_Exit);
entries[1].Set(wxACCEL_NORMAL, (int)'A', ID_About);
entries[2].Set(wxACCEL_NORMAL, (int)'T', ID_Test);
wxAcceleratorTable accel(3, entries);
if (accel.IsOk()) SetAcceleratorTable(accel);
else fprintf(stderr, "invalid accelerator table\n");
#endif
}
void MyFrame::
OnExit(wxCommandEvent& event)
{
Close(true);
}
void MyFrame::
OnAbout(wxCommandEvent& event)
{
wxMessageBox(L"OnAbout()", L"MyFrame::", wxOK, this);
}
void MyFrame::
OnTest(wxCommandEvent& event)
{
wxMessageBox(L"OnTest()", L"MyFrame::", wxOK, this);
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Exit, MyFrame::OnExit)
EVT_MENU(ID_About, MyFrame::OnAbout)
EVT_MENU(ID_Test, MyFrame::OnTest)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
****************************************************************************************
Thanks for spending your time on this,
Erwin
More information about the wx-users
mailing list