Bambookit Home    Bambookit GUI Tutorial

Back   

IV. Advanced Features

Chapter 13. Attachments

Attach to Widget



An attached widget is one that is gets displaced whenever the widget it is attached to is displaced OR resized.

The syntax is simply
attachToWidget="targetwidget,left,top,right,bottom"

<Widget> <Widget setName="w1"> <Drag> </Widget setName="w2" attachToWidget="w1,true,true,true,true"> <Widget/> </Widget>
The above skeleton example illustrates how one widget, 'w2' is attached to another, 'w1'. Whenever widget 'w1' is moved or resized then widget 'w2' will be displaced by a similar amount.

This can be seen in the table example, each column (a listbox) is attached to the listbox directly to its left. So whenever a column is resized, the remaining 'attached' widgets on its right are displaced by the appropriate number of pixels

Attachment to horizontal displacements?

We can listen in on only the horizontal displacements, in other words, of the x value changes (or the width) changes then we displace our attached widget by a similar amount. However if the y value changes (or the height changes) then we will ignore. The signature is simply,
attachToWidget="w1,true,false,true,false"
Which translates to left=true, top=false, right=true, bottom=false. We are listening for any changes to the left side and right side of the widget.

Attachment to vertical displacements?

We can listen in on only the horizontal displacements, in other words, of the y value changes (or the height) changes then we displace our attached widget by a similar amount. However if the x value changes (or the width changes) then we will ignore. The signature is simply,
attachToWidget="w1,false,true,false,true"
Which translates to left=false, top=true, right=false, bottom=true. We are listening for any changes to the top side and bottom side of the widget.

Conlusion

Attach to widget is an 'attachment' to any resize or displacement events, resulting in the displacement of the widget by the same amount. (i.e. if the size of widget is reduced by 20 pixels, the attached widget is displaced by x=-20 pixels.)

Back