Hello peeps.
I've been fiddling around with the wxAUI framework for a bit. Specifically with the wxAUINotebook widget (awesome stuff!)
There seems to be a problem though with missing events.
You can add/remove pages in the notebook. Adding pages fires off a wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED event. Closing pages does this too, except for the last page in the notebook. When you remove the last one, nothing fires.
Destroying pages, should fire wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, but this one seems to be ignored completely.
This missing last event is pretty critical unfortunately. In my current code, these events are used to enable/disable menuitems based on whether there's an active tab or not. The last event with disable them, but as it stands this never happens. There is a partial workaround; I use menuitems with shortcuts to remove tabs (Close, Close All, etc). These menuitem eventhandlers can do the updating of the menuitem states, but they will never be called if the user clicks the little X icon on each tab instead of using a menuitem.
Here is a proof of concept:
I've been fiddling around with the wxAUI framework for a bit. Specifically with the wxAUINotebook widget (awesome stuff!)
There seems to be a problem though with missing events.
You can add/remove pages in the notebook. Adding pages fires off a wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED event. Closing pages does this too, except for the last page in the notebook. When you remove the last one, nothing fires.
Destroying pages, should fire wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, but this one seems to be ignored completely.
This missing last event is pretty critical unfortunately. In my current code, these events are used to enable/disable menuitems based on whether there's an active tab or not. The last event with disable them, but as it stands this never happens. There is a partial workaround; I use menuitems with shortcuts to remove tabs (Close, Close All, etc). These menuitem eventhandlers can do the updating of the menuitem states, but they will never be called if the user clicks the little X icon on each tab instead of using a menuitem.
Here is a proof of concept:
SuperStrict Framework wx.wxApp Import brl.basic Import wx.wxFrame Import wx.wxTextCtrl Import wx.wxButton Import wx.wxPanel Import wx.wxAUI New MyApp.Run(); Type MyApp Extends wxApp Method OnInit:Int() Local frm:MyFrame = MyFrame(New MyFrame.Create(Null, wxID_ANY)); frm.Show(True); Return True; End Method End Type Const BTN_ADD:Int = 0; Const BTN_REM:Int = 1; Type MyFrame Extends wxFrame Field tabs:wxAuiNotebook; Method OnInit:Int() Local panel:wxPanel = New wxPanel.Create(Self, -1); Local sizer:wxBoxSizer = New wxBoxSizer.Create(wxVERTICAL); '// add /remove buttons sizer.Add(New wxButton.Create(panel, BTN_ADD, "Add"), 0, wxEXPAND | wxALL, 3); sizer.Add(New wxButton.Create(panel, BTN_REM, "Remove"), 0, wxEXPAND | wxALL, 3); '// hook em up Self.Connect(BTN_ADD, wxEVT_COMMAND_BUTTON_CLICKED, Add_Clicked); Self.Connect(BTN_REM, wxEVT_COMMAND_BUTTON_CLICKED, Remove_Clicked); '// create tab control Self.tabs = New wxAuiNotebook.Create(panel, -1); '// hook page change/close events Self.ConnectAny(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, tabs_PageChanged); Self.ConnectAny(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, tabs_PageClosed); sizer.Add(Self.tabs, 1, wxEXPAND | wxALL, 3); panel.SetSizer(sizer); End Method Function Add_Clicked(event:wxEvent) Local frm:MyFrame = MyFrame (event.parent); Local txt:wxTextCtrl = New wxTextCtrl.Create(frm, -1); frm.tabs.AddPage(txt, "Tab " + frm.tabs.GetPageCount(), True); End Function Function Remove_Clicked(event:wxEvent) Local frm:MyFrame = MyFrame (event.Parent); If(frm.tabs.GetPageCount() = 0) Then Return; End If '// This here should trigger a PAGE_CLOSE event, but it does not. frm.tabs.DeletePage(frm.tabs.GetSelection()); End Function Function tabs_PageChanged(event:wxEvent) Print("tabs_PageChanged!"); End Function Function tabs_PageClosed(event:wxEvent) Print("tabs_PageClosed!"); End Function End Type