This example takes you through the process of creating an object, examining its contents, and then modifying the object.
(defun button-enabled-p (capi:button)
(slot-value capi:button 'capi::enabled))
(setq button1 (make-instance 'capi:button))
button1
is enabled. (button-enabled-p button1)
This returns t
, so, buttons are enabled by default. The next step is to destructively modify button1
so that it is not enabled.
The Inspector Preferences dialog appears, so that you can change the current package of the inspector.
CAPI
and click OK . This changes the process package of the inspector to the CAPI
package, and the package name disappears from all the slots listed. This makes the display a lot easier to read.
enabled
into the Filter box and press Return.Button objects have a large number of slots, and so it is easier to filter out the slots that you do not want to see than to search through the whole list. After applying the filter, only one slot is listed.
enabled
to t
. A dialog appears into which you can type a new value for the slot enabled
.
Figure 13.5 Entering a new slot value
nil
in the dialog and click on OK . The Main area reflects the new value of ENABLED
.
Alt+P
.) (button-enabled-p button1)
This now returns nil
, as expected.
The next part of this example shows you how you can modify the slots of an object by pasting in the contents of the clipboard. By default, the background
slot of button objects is nil
. This example shows you how to modify the background
of button1
so that it is red.
"Hello World!"
TEXT
slot of button1
in the inspector. "Hello World!"
string into the text
slot of button1
. This sets the text
slot of button1
to the string.
You can confirm the effect of this change by displaying the button object. To do this, transfer it back into the listener and display it as follows:
This transfers the button object back into the listener. As feedback, the string representation of the object is printed in the listener above the current prompt. The object is automatically transferred to the *
variable so that it can be operated on.
(capi:contain *)
This displays a window containing the button object. Note that the text now reads "Hello World!", as you would expect. Note further that you cannot click on the button; it is not enabled. This is because you modified the setting of the enabled
slot in the earlier part of this example.
You can also use Slots> Copy to copy this value to other objects in the inspector, or even to other tools.