Next Prev Up Top Contents Index

choice-selected-item

Generic Function
Summary

The function choice-selected-item returns the currently selected item in a single selection choice.

Signature

choice-selected-item choice

Signature

(setf choice-selected-item) item choice

Description

The function choice-selected-item returns the currently selected item in a single selection choice. A setf method is provided as a means of setting the selection. Note that the items are compared by choice 's test-function - see collection or the example below.

It is an error to call this function on choices with different interactions -- in that case, you should use choice-selected-items.

Example

This example illustrates setting the selection. First we set up a single selection choice -- in this case, a list-panel.

(setq list (capi:contain
            (make-instance 'capi:list-panel
                           :items '(a b c d e)
                           :selection 2)
            :process nil))

The following code line returns the selection of the list panel.

(capi:choice-selected-item list)

The selection can be changed, and the change viewed, using the following code.

(setf (capi:choice-selected-item list) 'e) (capi:choice-selected-item list)

 

This example illustrates the effect of the test-function . Make a choice with test-function eq :

(setf *list* 
      (capi:contain 
       (make-instance 'capi:list-panel 
                      :items (list "a" "b" "c") 
                      :selection 0 
                      :test-function 'eq
                      :visible-min-height :text-height)
       :process nil))

 

This call loses the selection since (eq "b" "b") fails:

(setf (capi:choice-selected-item *list*) "b")

Change the test function:

(setf (capi:collection-test-function *list*) 'equal)

This call sets the selection since (equal "b" "b") succeeds:

(setf (capi:choice-selected-item *list*) "b")
See also

choice
choice-selected-items
collection


LispWorks CAPI Reference Manual - 13 Mar 2003

Next Prev Up Top Contents Index