Now I have the following construct:
Code: Select all
class MyNotebookContainer
{
wxAuiNotebook* m_notebook = NULL;
MainWindow* m_parent = NULL;
MyNotebookContainer(MainWindow* parent)
{
m_parent = parent;
m_notebook = new wxAuiNotebook(parent, wxID_ANY, ...);
m_notebook->Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSE, &MyNotebookContainer::OnNotebookPageClose, this);
m_notebook->Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGING, &MyNotebookContainer::OnNotebookPageChanging, this);
}
OnNotebookPageClose(wxAuiNotebookEvent& evt)
{
wxAuiNotebook* nb = (wxAuiNotebook*)evt.GetEventObject();
if (nb != m_notebook) { evt.Veto(); return; } // <----- run into it here!
....
}
OnNotebookPageChanging(wxAuiNotebookEvent& evt)
{
wxAuiNotebook* nb = (wxAuiNotebook*)evt.GetEventObject();
if (nb != m_notebook) { evt.Veto(); return; } // <----- run into it here!
....
}
}
class MainWindow : public wxFrame
{
wxAuiManager m_auiManager;
MyNotebookContainer* m_container = NULL;
MainWindow:MainWindow()
{
m_container = new MyNotebookContainer(this);
m_auiManager.SetManagedWindow(this);
m_auiManager.AddPane(m_container->m_notebook, ...);
m_auiManager.Update();
}
}
If I use Connect within the MainWindow and forward the events to the container, everything looks good.
Can someone tell me what's the difference here? In my opinion it should not matter if I use Bind or Connect.