Next Previous Up Top Contents Index

7.2 A tour of gadgets

7.2.1 General properties of gadgets

Each class of gadget has a set of associated slots that help define the properties for that class. Different classes of gadget have different sets of slots. This section describes some of the more important slots available. The following slots are common across most (though not necessarily all) gadget classes.

gadget-label

This slot holds the label that is associated with a gadget.

For an item on a menu or a button, for example, this label appears on the gadget itself. For a gadget such as a text field or a border, the label may be displayed next to the gadget.
A label is usually a text string, but can often be an icon, such as is often found on the buttons of an application's toolbar.
If a gadget does not have a label, gadget-label returns #f.
gadget-enabled?

This slot specifies whether or not the gadget is active--that is, whether the user of your application can interact with the gadget. All gadgets have a gadget-enabled? slot. The gadget-enabled? slot returns either #t or #f. When a gadget is disabled, it is usually grayed out on the screen, and cannot be interacted with in any way.
gadget-value

This slot holds the value of the gadget. Most gadgets can have a value of some kind; these are general instances of the <value-gadget> class. However, gadgets such as borders that are placed around elements have no associated value.

Generally speaking, you can think of the gadget value as a value that the user of your application has assigned to the gadget. The gadget-value-type depends on the class of gadget involved. For a text field, the gadget value is the string typed into the text field. For a gadget with several items (see gadget-items below), such as a list, the gadget value is the selected item. For a radio button, the gadget value is a boolean that denotes whether the button is selected or not.
If a gadget does not have any values, gadget-value returns #f.

All of the slots described above can also be specified as init-keyword values when creating an instance of a gadget. In all cases, the init-keyword name is the same as the slot name, but without the preceding gadget-. Thus, a gadget can be enabled or disabled when it is first created by specifying the enabled?: init-keyword appropriately.

Gadgets can also have a variety of associated callbacks. A callback is a function that is invoked when a particular event occurs that is associated with a given gadget, such as pressing a button. It is the primary technique you use to make your applications "do something". Like gadget properties, different classes of gadget can have different callback types available. For an introduction to callbacks, see Section 7.2.7 on page 113.


Building Applications Using DUIM - 26 May 1999

Next Previous Up Top Contents Index