I've started learning wxWidget and have problem handling button events.
I've started to create a small app, and created a panel with a sizer and some buttons, and it appears well, but when click on the button I don't receive the event for some reason.
Code: Select all
#include <wx/wx.h>
class SidebarPanel : public wxPanel
{
public:
SidebarPanel(wxWindow* parent);
void onExit(wxCommandEvent& event);
private:
wxButton* mConvertButton;
wxButton* mExitButton;
wxTextCtrl* mTextctrl;
wxDECLARE_EVENT_TABLE();
};
wxBEGIN_EVENT_TABLE(SidebarPanel, wxPanel)
EVT_BUTTON(wxID_EXIT, SidebarPanel::onExit)
wxEND_EVENT_TABLE()
SidebarPanel::SidebarPanel(wxWindow* parent) :
wxPanel(parent)
{
wxColour col;
col.Set(wxT("#4f5049"));
SetBackgroundColour(col);
wxGridSizer* sizer = new wxGridSizer(3,3,1,1);
mConvertButton = new wxButton(this, wxID_CONVERT);
mExitButton = new wxButton(this, wxID_EXIT);
sizer->Add(mConvertButton, 1, wxALL);
sizer->Add(mExitButton, 1, wxALL);
SetSizerAndFit(sizer);
}
void SidebarPanel::onExit(wxCommandEvent& event)
{
std::cout<<"DrawPane::onExit"<<std::cout;
Close(TRUE);
}
Stefi