Attributes interface
Attributes of an object can be get and set. Getting the value of an
object's attribute is straingtforward. As an example consider a button
widget and an attribute called buttonLabel.
value <- get button buttonLabel
The syntax for setting or updating an attribute is only slightly more
complex. At the simplest level it is just:
set button [ buttonLabel := value ]
However as the list notation would indicate, you can set or update multiple
attributes of the same object in one go:
set button [ buttonLabel := value, buttonFocusOnClick := False ]
You are not limited to setting the value of an attribute, you can also
apply an update function to an attribute's value. That is the function
receives the current value of the attribute and returns the new value.
set spinButton [ spinButtonValue :~ (+1) ]
There are other variants of these operators, (see AttrOp). ':=>' and
':~>' and like ':=' and ':~' but operate in the IO monad rather
than being pure. There is also '::=' and '::~' which take the object
as an extra parameter.
Attributes can be read only, write only or both read/write.
|