Reputation: 4346
wxWidgets 2.9.1 documentation recommends the new way of creating staticboxes - we should create all controls inside the staticbox as its children.
However, there's a problem with keyboard navigation when you have more than one staticbox in your dialog/panel. There is no way to move cursor between controls placed in different staticboxes. Methods wxWindow::MoveAfterInTabOrder() and wxWindow::MoveBeforeInTabOrder are useless here, since they work only with siblings of the same parent window.
This sample code creates dialog with two staticboxes, each of them being the parent of the two edit controls. What should I do to be able to navigate with Tab key from edit control #2 to edit control #3?
void CreateTestDialog(wxWindow* parent)
{
wxWindowID id = 10010;
long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL;
wxDialog dlg;
dlg.SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
if (dlg.Create(parent, id, wxT("Tab Order Test"), wxDefaultPosition, wxDefaultSize, style))
{
wxBoxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
dlg.SetSizer(sizer1);
wxStaticBox* staticbox1 = new wxStaticBox(&dlg, wxID_ANY, _("Static1"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
wxStaticBoxSizer* sizer2 = new wxStaticBoxSizer(staticbox1, wxVERTICAL);
sizer1->Add(sizer2, 0, wxGROW|wxALL, 5);
wxTextCtrl* m_ctl_text1 = new wxTextCtrl( staticbox1, 10011 );
sizer2->Add(m_ctl_text1, 0, wxGROW|wxALL, 5);
wxTextCtrl* m_ctl_text2 = new wxTextCtrl( staticbox1, 10012);
sizer2->Add(m_ctl_text2, 0, wxGROW|wxALL, 5);
wxStaticBox* staticbox2 = new wxStaticBox(&dlg, wxID_ANY, _("Static2"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
wxStaticBoxSizer* sizer3 = new wxStaticBoxSizer(staticbox2, wxVERTICAL);
sizer1->Add(sizer3, 0, wxGROW|wxALL, 5);
wxTextCtrl* m_ctl_text3 = new wxTextCtrl( staticbox2, 10013);
sizer3->Add(m_ctl_text3, 0, wxGROW|wxALL, 5);
wxTextCtrl* m_ctl_text4 = new wxTextCtrl( staticbox2, 10014);
sizer3->Add(m_ctl_text4, 0, wxGROW|wxALL, 5);
dlg.ShowModal();
}
}
Please don't advice me to use the old way of creating controls (as siblings of the staticboxes). The new way of creating staticboxes solves the nasty display glitch - that's the real problem I'm trying to solve.
Thanks
Wacek
Upvotes: 1
Views: 893
Reputation: 4346
Problem was finally solved in the pre-release version of wxWidgets 2.9.5.
More information can be found on the corresponding ticket page
I did answer to my own question, because there were no other answers. Maybe this will be useful for someone else in the future.
Upvotes: 1