Iterate through all GUI elements in a dialog box?
by Vern Jensen · in Torque Game Builder · 06/10/2009 (4:58 pm) · 4 replies
Are there any methods to iterate through all the child elements of a control? I'd like to make a method that dynamically resizes my dialog boxes (and therefore resizes all children elements), and am curious if this is possible.
[FYI, all the built-in methods Torque supplies for automatically resizing a dialog box according to the current resolution are horribly broken, hence why I want to roll my own.]
[FYI, all the built-in methods Torque supplies for automatically resizing a dialog box according to the current resolution are horribly broken, hence why I want to roll my own.]
#2
06/10/2009 (9:04 pm)
Totally forgot about the .dump() command. Thanks!
#3
> all the built-in methods Torque supplies for automatically resizing a dialog box according to the current resolution are horribly broken, hence why I want to roll my own
i hear your frustration,
but would encourage you to stick with it.
i've made a lot of moderately fancy compound-gui controls and it's usually been possible to get them to do what you want w/ the existing stuff. the problem is that implementing complex stuff in script can get laggy.
the main gotcha for me was that if you want a child to stick to its parent's left edge you give the child "horizSizing = right", and if you want it to stick to the top you give it "vertSizing = bottom". ie they're backwards. "horizSizing = width" means that if the parent's extent changes by dX then the child's extent will also change by dX. etc. it's true you can't get every behaviour you want with these, but you can get a lot of them. but yes, they're also quite unintuitive at first.
06/10/2009 (10:40 pm)
re %i = 1; i < %count, i think you want to start at i = 0.> all the built-in methods Torque supplies for automatically resizing a dialog box according to the current resolution are horribly broken, hence why I want to roll my own
i hear your frustration,
but would encourage you to stick with it.
i've made a lot of moderately fancy compound-gui controls and it's usually been possible to get them to do what you want w/ the existing stuff. the problem is that implementing complex stuff in script can get laggy.
the main gotcha for me was that if you want a child to stick to its parent's left edge you give the child "horizSizing = right", and if you want it to stick to the top you give it "vertSizing = bottom". ie they're backwards. "horizSizing = width" means that if the parent's extent changes by dX then the child's extent will also change by dX. etc. it's true you can't get every behaviour you want with these, but you can get a lot of them. but yes, they're also quite unintuitive at first.
#4
06/10/2009 (10:41 pm)
also note that the getCount() / getObject() pattern is how to iterate through all the children of any SimSet, and GuiControls inherit from SimGroup which inherits from SimSet.
Torque 3D Owner Ted Southard
%count = playGui.getCount(); for(%i = 1; %i < %count; %i++) { %ctrl = playGui.getObject(%i); //Do things to %ctrl }