I have a custom control class, that is derived from wxControl and that is composed by some other standard control (I can't post the original code becouse it is too long and complex so, I will write an example):
Code: Select all
...
class MyControl : public wxControl {
wxTextCtrl *text;
wxButton *btn;
public:
MyControl(...) : wxControl(...) {
auto *sizer = new wxBoxSizer(wxVERTICAL);
btn = new wxButton(this, wxID_ANY, _T("btn"));
text = new wxTextCtrl(...);
sizer->Add(text);
sizer->Add(btn);
SetMainSizer(sizer);
btn->Bind(wxEVT_BUTTON, &MyControl::onBtnClick, this);
}
void onBtnClick(wxCommandEvent &e) {
// todo
}
}
...
Code: Select all
...
MyControl *myCtrl = new MyControl(...);
myCtrl->Bind(MY_EVT, [](MyCoolEvt &e){
std::cout << e->GetMyData() << std::endl;
});
...