the code below works , if you press any key a message box popup showing the key code
the problem is when i add a widget (button , panel ...) to the window , the function on_keydown() no longer works
is this related to maybe losing focus ?
Code: Select all
#include <wx/wx.h>
class cFrame : public wxFrame{
public:
cFrame(const wxString& title):
wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(1024, 600)){
this->Centre( wxBOTH );
this->Connect(wxEVT_CHAR, wxKeyEventHandler(on_keydown));
}
void on_keydown( wxKeyEvent& event ){
wxMessageBox(wxString::Format(L"KeyDown: %i\n", (int)event.GetKeyCode()));
}
};
class MyApp : public wxApp{
public:
virtual bool OnInit(){
cFrame *simple = new cFrame(wxT("wxApp"));
simple->Show(true);
return true;
}
};
IMPLEMENT_APP(MyApp)