I have one wxEdit field and one BitmapButton in my project.
If the user types in wxEdit and presses the return-key the function of the Bitmap shall become started.
I thought I could create a function to check each KeyEvent for return and call the function of my BitmapButton... but I've got some trouble at starting the BitmapButton function...
Code: Select all
void PressReturn(wxKeyEvent& event)
{
if(event.GetKeyCode() == WXK_RETURN)
{
TrainingFrm::WxBitmapButton1Click0(); // What must stand here?
}
event.Skip();
}
void TrainingFrm::CreateGUIControls()
{
wxInitAllImageHandlers(); //Initialize graphic format handlers
WxPanel2 = new wxPanel(WxPanel1, ID_WXPANEL2, wxPoint(0, 471), wxSize(800, 105));
WxPanel2->SetBackgroundColour(wxColour(0,0,0));
WxEdit1 = new wxTextCtrl(WxPanel2, ID_WXEDIT1, wxT(""), wxPoint(285, 40), wxSize(365, 35), 0, wxDefaultValidator, wxT("WxEdit1"));
WxEdit1->SetBackgroundColour(wxColour(255,255,255));
WxEdit1->SetFont(wxFont(20, wxSWISS, wxNORMAL, wxNORMAL, false));
wxBitmap WxBitmapButton1_BITMAP (wxT("gfx/button/btn_start_100x35.png"), wxBITMAP_TYPE_PNG);
WxBitmapButton1 = new wxBitmapButton(WxPanel2, ID_WXBITMAPBUTTON1, WxBitmapButton1_BITMAP, wxPoint(650, 40), wxSize(100, 35), wxBU_AUTODRAW, wxDefaultValidator, wxT("WxBitmapButton1"));
WxEdit1->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(PressReturn));
}
void TrainingFrm::WxBitmapButton1Click0(wxCommandEvent& event)
{
// MY CODE
}
Most of my code is auto-generated by wxDevC++
Thank you
-Eric