This example takes you through the process of creating an object, examining its contents, and then modifying the object.
(setq button1 (make-instance 'capi:button))
button-enabled
to find out whether
button1
is enabled.
(capi:button-enabled button1)
This returns
t
. So we see buttons are enabled by default. The next step is to destructively modify
button1
so that it is not enabled, but first we will make the Inspector display a little simpler.
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.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
.
A dialog appears into which you can type a new value for the slot
enabled
.
Figure 17.5 Entering a new slot value
nil
(or select it from the history) and click on
OK
.
The attributes and values area shows the new value of the
enabled
slot.
Alt+P
or
History > Previous
.
(capi:button-enabled 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. This example shows you how to modify the
text
and
font
of
button1
.
Return
:
"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.
Return
:(let ((font (capi:simple-pane-font button1)))
(if font
(gp:find-best-font
button1
(apply 'gp:make-font-description
(append (list :size 30)
(gp:font-description-attributes
(gp:font-description
(capi:simple-pane-font button1))))))
(gp:make-font-description :size 30)))
This form simply calculates a large font object suitable for the button object.
FONT
slot of
button1
in the Inspector.
font
slot of
button1
.
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, and that the font size is larger than the default size size for buttons. 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.
LispWorks IDE User Guide (Macintosh version) - 25 Nov 2011