Reputation: 819
I have created a class called ValCtrl that extends wxPanel. Each instance manages a wxCheckBox, a wxSlider, and a wxSpinCtrl. I am dynamically binding the events to methods in ValCtrl.
The wxSlider and wxCheckBox event handling are working, but I've done something wrong with the wxSpinCtrl, and my handlers are not being called. The program compiles and runs, and I haven't found enough help in the documentation. Any ideas?
Here are my instantiations:
linkCheckBox = new wxCheckBox(this, wxID_ANY, stim->name, wxPoint(-1,-1), wxSize(linkCheckBoxSX, defaultS));
slider = new wxSlider(this, wxID_ANY, 0, 0, 100, wxPoint(-1,-1), wxSize(sliderSX, sliderSY), wxSL_HORIZONTAL);
slider->SetRange(stim->minValue, stim->maxValue);
slider->SetValue(stim->value);
spinCtrl = new wxSpinCtrl(this, wxID_ANY, "0", wxPoint(-1,-1), wxSize(spinCtrlSX, spinCtrlSY));
spinCtrl->SetRange(stim->minValue, stim->maxValue);
spinCtrl->SetValue(stim->value);
Here are my binds:
slider->Bind(wxEVT_SCROLL_THUMBTRACK, &ValCtrl::OnScroll, this);
slider->Bind(wxEVT_SCROLL_CHANGED, &ValCtrl::OnScroll, this);
spinCtrl->Bind(wxEVT_SPIN, &ValCtrl::OnSpin, this);
spinCtrl->Bind(wxEVT_COMMAND_TEXT_ENTER, &ValCtrl::OnEntered, this);
linkCheckBox->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &ValCtrl::OnCheck, this);
Here are my handler method declarations:
void OnCheck(wxCommandEvent& event);
void OnEntered(wxCommandEvent& event);
void OnScroll(wxScrollEvent& event);
void OnSpin(wxSpinEvent& event);
Upvotes: 0
Views: 1418
Reputation: 819
Read over headers and found wxEVT_COMMAND_SPINCTRL_UPDATED. I'm using 2.9 which apparently changed how wxSpinCtrl events are dispatched and captured since 2.8.
Working now. Correction is below for any other curious party.
spinCtrl->Bind(wxEVT_SPIN, &ValCtrl::OnSpin, this);
spinCtrl->Bind(wxEVT_COMMAND_TEXT_ENTER, &ValCtrl::OnEntered, this);
turns into:
spinCtrl->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &ValCtrl::OnSpin, this);
Upvotes: 3