GuiCheckBoxCtrl inside GUIScrollCtrl inside GUITabPageCtrl
by Rich Adam · in Torque 3D Professional · 03/25/2010 (9:20 am) · 11 replies
I have a large number of checkboxes in a GUITabPageCtrl. So I added a GUIScrollCtrl inside the GUITabPageCtrl. I generate a large number of GuiCheckBoxCtrl objects via script inside the GUIScrollCtrl. The x and y positions for the objects for the GuiCheckBoxCtrl objects start out at -1999 -35321. When I step through the code that generates them, they appear to be cordinates that I expect (e.g. 20 20).
Before I inserted the GUIScrollCtrl the object placement was proper. What could be placing these objects in these positions?
Additional info: when I dump the object after it is constructed it has the desired coords. When I dump it after it is added to the GUIScrollCtrl it's coords are 1, 1. Every GuiCheckBoxCtrl object added to the GUIScrollCtrl has the same 1, 1 coords when dumped directly after being added. Hmmmm...
Before I inserted the GUIScrollCtrl the object placement was proper. What could be placing these objects in these positions?
Additional info: when I dump the object after it is constructed it has the desired coords. When I dump it after it is added to the GUIScrollCtrl it's coords are 1, 1. Every GuiCheckBoxCtrl object added to the GUIScrollCtrl has the same 1, 1 coords when dumped directly after being added. Hmmmm...
About the author
#2
I have scores of checkboxes vertically arranged and the number is variable based how many objects in the scene we wish to control.
I will look at the other controls, but I would like to understand what is going on as I think being able to accurately place objects in a scroll container is useful.
Thanks Ryan.
03/25/2010 (1:04 pm)
I am seeing -1999 -35321 for the first object placed via inspection from the Gui Editor. The second object is at -1964 -35282. Subsequent objects monotonically increase in both x and y in their positioning with the last object being actually visible at 1 1.I have scores of checkboxes vertically arranged and the number is variable based how many objects in the scene we wish to control.
I will look at the other controls, but I would like to understand what is going on as I think being able to accurately place objects in a scroll container is useful.
Thanks Ryan.
#3
03/25/2010 (1:17 pm)
Ok, I know whats going on now. Since the last control added is the one visible the scroll control has decided to basically scroll down on you. The scroll control works by adjusting the child controls position inside of its self so that anything outside of the update region is invisible. So basically when you scroll down it subtracts from the y position until it is out of the update region. If you scrolled all the way up you would see that the first control would move to the 1 1 position.
#4
It is moving first object by 35, 39, the second by 35, 59, the third by 35, 79 the fourth by 35, 99 and so on.
I am at a loss to figure out where these offsets are coming from.
03/25/2010 (2:08 pm)
That would explain the y component, but not casting objects off into negative x space. Yes? Additionally, I do not seem to be able to scroll to see the other objects. It is moving first object by 35, 39, the second by 35, 59, the third by 35, 79 the fourth by 35, 99 and so on.
I am at a loss to figure out where these offsets are coming from.
#5
Edit:
Also, are you getting anything in your console related to the scroll control?
03/25/2010 (2:18 pm)
Hmmm...whats the settings on your scroll control?Edit:
Also, are you getting anything in your console related to the scroll control?
#6
willFirstRespond = "1";
hScrollBar = "alwaysOn";
vScrollBar = "alwaysOn";
lockHorizScroll = "0";
lockVertScroll = "0";
constantThumbHeight = "0";
childMargin = "0 0";
mouseWheelScrollSpeed = "-1";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "1";
Profile = "GuiScrollProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "4 4";
Extent = "588 524";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
The console is silent on this, good question though.
Here is a sample of the checkbox creation script:
%checkbox = new GuiCheckBoxCtrl(%checkbox_name)
{
useInactiveState = "0";
text = %name;
groupNum = %group_num;
buttonType = "ToggleButton";
useMouseEvents = "0";
isContainer = "0";
Profile = "GuiCheckBoxProfile";
HorizSizing = "center";
VertSizing = "center";
position = ""@%x@" "@%y@"";
Extent = "140 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Variable = %variable;
Command = "setGroupState("@%checkbox_name@","@%variable@");";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
I am stumped.
03/25/2010 (2:31 pm)
new GuiScrollCtrl(WorldObjectsScrollCtrl) {willFirstRespond = "1";
hScrollBar = "alwaysOn";
vScrollBar = "alwaysOn";
lockHorizScroll = "0";
lockVertScroll = "0";
constantThumbHeight = "0";
childMargin = "0 0";
mouseWheelScrollSpeed = "-1";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "1";
Profile = "GuiScrollProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "4 4";
Extent = "588 524";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
The console is silent on this, good question though.
Here is a sample of the checkbox creation script:
%checkbox = new GuiCheckBoxCtrl(%checkbox_name)
{
useInactiveState = "0";
text = %name;
groupNum = %group_num;
buttonType = "ToggleButton";
useMouseEvents = "0";
isContainer = "0";
Profile = "GuiCheckBoxProfile";
HorizSizing = "center";
VertSizing = "center";
position = ""@%x@" "@%y@"";
Extent = "140 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Variable = %variable;
Command = "setGroupState("@%checkbox_name@","@%variable@");";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
I am stumped.
#7
GuiTabPageCtrl -> GuiScrollCtrl -> GuiStackControl -> [set of GuiCheckBoxCtrl-s]
This way all of your controls will be automatically aligned.
The GuiScrollCtrl is made to handle only one "large" control, so you can scroll around, not "many small objects".
You can use either GuiStackControl or GuiControlArrayControl as a "container" of your check-boxes, both are made to handle multiple objects inside.
03/25/2010 (2:31 pm)
Make it like that:GuiTabPageCtrl -> GuiScrollCtrl -> GuiStackControl -> [set of GuiCheckBoxCtrl-s]
This way all of your controls will be automatically aligned.
The GuiScrollCtrl is made to handle only one "large" control, so you can scroll around, not "many small objects".
You can use either GuiStackControl or GuiControlArrayControl as a "container" of your check-boxes, both are made to handle multiple objects inside.
#8
03/25/2010 (2:38 pm)
Yeah, I think all the controls are playing havoc with the scroll control. Try this as a test, add just a guiControl in the scroll control and then add your check boxes to it. Just re-size the guiControl as you add the checkboxes. You should get the scroll bars then. But I would definitely look into the guiStack and guiControlArray.
#9
Embedding a GuiStackControl in the scroller did it. Thanks. A little odd that a scroll control cannot handle multiple objects gracefully, but no matter it is working now. I had to muck with
ChangeChildSizeToFit = "0";
ChangeChildPosition = "0";
to allow for indentation of grouped items, but order from chaos has been established.
Thanks again Fyodor and Ryan. I am now a bit Torquier than I was this morning.
03/25/2010 (3:02 pm)
Good!!Embedding a GuiStackControl in the scroller did it. Thanks. A little odd that a scroll control cannot handle multiple objects gracefully, but no matter it is working now. I had to muck with
ChangeChildSizeToFit = "0";
ChangeChildPosition = "0";
to allow for indentation of grouped items, but order from chaos has been established.
Thanks again Fyodor and Ryan. I am now a bit Torquier than I was this morning.
Torque Owner Ryan Mick
Red Witch Entertainment
How many check boxes are we talking about?
Are they lined up vertically or horizontally?
Where are you seeing -1999 -35321? (Gui Editor or code)
Positioning should be relative to its container, but the scroll container does actually modify the position of its children to scroll them into or out of the scroll controls update region. If you want the check boxes to be nicely ordered try having a look at guiStackCtrl or guiCtrlArrayCtrl.