Attached you will find a patch that changes the order in which widgets
are created in the generated code. I noticed in my applications that the
(keyboard) tab order does not always match the order of the widgets as
they are laid out on the screen. Since by default, tab order is the same
as initialization order, I started looking at the initalization order in
the code that wxGlade generates.
I noticed that the list of init statements for widgets is reverse()d
before it is written out, presumably to make sure that parents are
initialized before their children. Instead of reverse()ing the list of
init calls, the patch tracks the dependency between child and parent
widgets. It then generates an initialization order that ensures that a)
parents are initialized before their children, and b) widgets are
initialized in the order they have been read from the wxg file.
I've tested this patch on a project containing about 80 top level panels
and 8 windows; there are no errors when running the resulting
application, an the tab order is as expected. I've had to make one
change to the generation of StaticBoxSizers: the StaticBoxes are
sometimes generated after the controls which they "contain", so I've
added a call to Lower to make sure that the StaticBoxes don't lie on top
of the controls. I believe that this is only an issue on Mac OS: it
would make the controls unreachable by mouse.
Also attached is a wxg file that demonstrates the issue: before applying
the patch, panel_1 is generated *after* panel_2.
I would be grateful if you could test this patch with your own projects,
to see if it doesn't have any nasty side effects :-)
Roel van Os