All Manuals > CAPI User Guide and Reference Manual > 21 CAPI Reference Entries

choice-selected-item Accessor

Summary

Returns the currently selected item in a single selection choice.

Package

capi

Signature

choice-selected-item choice => item

(setf choice-selected-item) item choice => item

Arguments
choice
A choice.
item
A Lisp object.
Values
item
A Lisp object.
Description

The accessor choice-selected-item accesses 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 the test-function of choice - 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.

Examples

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)))

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.

(capi:apply-in-pane-process
 list #'(setf capi:choice-selected-item) 'e list)
 
(capi:choice-selected-item list)

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

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

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

(capi:apply-in-pane-process
 *list* #'(setf capi:choice-selected-item) 
 "b" *list*)

Change the test function:

(capi:apply-in-pane-process
 *list* #'(setf capi:collection-test-function) 
 'equal *list*)

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

(capi:apply-in-pane-process
 *list* #'(setf capi:choice-selected-item) 
 "b" *list*)
See also

choice
choice-selected-item-p
choice-selected-items
collection
5 Choices - panes with items


CAPI User Guide and Reference Manual (Windows version) - 01 Dec 2021 19:33:57