Attachments and Controls
Attachments in its simplest form is like a piece of string 'attaching' one control to another. If the main control is moved, the 'attached' widget matches this displacement. If the main control is resized, the 'attached' widget matches this displacement (either relocated or resized).
Let me demonstrate how these attachments are used in creating a 'complex' control from various basic controls. Let's take the example of the collapsible menu bars. In the applet below you would see 3 'expanded' collapsible menu bars. Each menu bar is attached to the one above, thus whenever the top menu bar is 'minimized' the attached menu bars below are relocated by a similar displacement. The top menu bar displacing the second menu bar, the second menu displacing the third one. Like a row of dominos.
What is the semantics of this mechanism?
The semantics are handled within the XML script, setting attributes within an XML element. In the example above, the 'List' control is attached to the 'Button' control ,(.. attachToWidget="Button,false,true,false,true" ..)
The parameters: widget name, attach to x displacement, attach to y displacement, attach to width displacement, attach to height displacement.
All this means is the control, 'List', is attached to the control, 'Button', along the y-axis (changes to the y co-ordinate or height will affect the 'attached' controls location).
Now if you wish to modify the 'attached' control's size whenever the the 'root' control changes location or size than we would use the 'attachToContainer' attribute. Same parameter list, the difference is only that the 'root' control gets its size modified whenever the location and/or size changes.
For more script examples, please visit the the Tutorials section.