wxSpinCtrl 不生成事件
我创建了一个名为 ValCtrl 的类,它扩展了 wxPanel。每个实例管理一个wxCheckBox、一个wxSlider和一个wxSpinCtrl。我将事件动态绑定到 ValCtrl 中的方法。
wxSlider 和 wxCheckBox 事件处理正在工作,但我对 wxSpinCtrl 做了一些错误,并且我的处理程序没有被调用。该程序编译并运行,但我在文档中没有找到足够的帮助。有什么想法吗?
这是我的实例化:
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);
这是我的绑定:
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);
这是我的处理程序方法声明:
void OnCheck(wxCommandEvent& event);
void OnEntered(wxCommandEvent& event);
void OnScroll(wxScrollEvent& event);
void OnSpin(wxSpinEvent& event);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仔细阅读标题并找到 wxEVT_COMMAND_SPINCTRL_UPDATED。我使用的是 2.9,它显然改变了自 2.8 以来 wxSpinCtrl 事件的调度和捕获方式。
现在工作了。对于任何其他好奇的一方,更正如下。
变成:
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.
turns into: