Replace Connect() with Bind() in all samples and utils too
Still use Connect() in unit tests which were written explicitly for it and in EventConnector, which can't use Bind() as it uses a variable for the event type. No real changes, just use the newer and more convenient function.
This commit is contained in:
@@ -92,8 +92,7 @@ public:
|
||||
: wxButton(parent, BUTTON_ID, label)
|
||||
{
|
||||
// Add a dynamic handler for this button event to button itself
|
||||
Connect(wxEVT_BUTTON,
|
||||
wxCommandEventHandler(MyEvtTestButton::OnClickDynamicHandler));
|
||||
Bind(wxEVT_BUTTON, &MyEvtTestButton::OnClickDynamicHandler, this);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -307,8 +306,8 @@ bool MyApp::OnInit()
|
||||
frame->Show(true);
|
||||
|
||||
// Add a dynamic handler at the application level for the test button
|
||||
Connect(MyEvtTestButton::BUTTON_ID, wxEVT_BUTTON,
|
||||
wxCommandEventHandler(MyApp::OnClickDynamicHandlerApp));
|
||||
Bind(wxEVT_BUTTON, &MyApp::OnClickDynamicHandlerApp, this,
|
||||
MyEvtTestButton::BUTTON_ID);
|
||||
|
||||
// success: wxApp::OnRun() will be called which will enter the main message
|
||||
// loop and the application will run. If we returned false here, the
|
||||
@@ -427,15 +426,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
// event handlers (see class definition);
|
||||
|
||||
// Add a dynamic handler for this button event in the parent frame
|
||||
Connect(m_testBtn->GetId(), wxEVT_BUTTON,
|
||||
wxCommandEventHandler(MyFrame::OnClickDynamicHandlerFrame));
|
||||
Bind(wxEVT_BUTTON, &MyFrame::OnClickDynamicHandlerFrame, this,
|
||||
m_testBtn->GetId());
|
||||
|
||||
// Bind a method of this frame (notice "this" argument!) to the button
|
||||
// itself
|
||||
m_testBtn->Connect(wxEVT_BUTTON,
|
||||
wxCommandEventHandler(MyFrame::OnClickDynamicHandlerButton),
|
||||
NULL,
|
||||
this);
|
||||
m_testBtn->Bind(wxEVT_BUTTON, &MyFrame::OnClickDynamicHandlerButton, this);
|
||||
|
||||
mainSizer->Add(m_testBtn);
|
||||
panel->SetSizer(mainSizer);
|
||||
@@ -545,19 +541,13 @@ void MyFrame::OnConnect(wxCommandEvent& event)
|
||||
{
|
||||
if ( event.IsChecked() )
|
||||
{
|
||||
m_btnDynamic->Connect(wxID_ANY, wxEVT_BUTTON,
|
||||
wxCommandEventHandler(MyFrame::OnDynamic),
|
||||
NULL, this);
|
||||
Connect(Event_Dynamic, wxEVT_MENU,
|
||||
wxCommandEventHandler(MyFrame::OnDynamic));
|
||||
m_btnDynamic->Bind(wxEVT_BUTTON, &MyFrame::OnDynamic, this);
|
||||
Bind(wxEVT_MENU, &MyFrame::OnDynamic, this, Event_Dynamic);
|
||||
}
|
||||
else // disconnect
|
||||
{
|
||||
m_btnDynamic->Disconnect(wxID_ANY, wxEVT_BUTTON,
|
||||
wxCommandEventHandler(MyFrame::OnDynamic),
|
||||
NULL, this);
|
||||
Disconnect(Event_Dynamic, wxEVT_MENU,
|
||||
wxCommandEventHandler(MyFrame::OnDynamic));
|
||||
m_btnDynamic->Unbind(wxEVT_BUTTON, &MyFrame::OnDynamic, this);
|
||||
Unbind(wxEVT_MENU, &MyFrame::OnDynamic, this, Event_Dynamic);
|
||||
}
|
||||
|
||||
UpdateDynamicStatus(event.IsChecked());
|
||||
|
Reference in New Issue
Block a user