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

NextPrevUpTopContentsIndex

list-panel-search-with-function

Function
Summary

Searches a list-panel.

Signature

list-panel-search-with-function list-panel function arg &key start-index wrap-around reset-time

Arguments

list-panel

A list-panel.

function

A function taking two arguments. The first is arg , the second is an item in list-panel .

arg

Any Lisp object.

start-index

An integer, default 0.

reset-time

A real number. The default is an internal value which can be set by set-list-panel-keyboard-search-reset-time.

wrap-around

A boolean, default t.

Description

The function list-panel-search-with-function searches list-panel using function . list-panel-search-with-function is intended to simplify the implementation of the keyboard-search-callback of list-panel.

list-panel-search-with-function searches list-panel for a match. It applies function to each item and arg , until function returns non-nil.

When function returns non-nil, list-panel-search-with-function returns three values: the index of the item, arg , and reset-time .

The search starts at start-index if supplied, and at 0 otherwise. When the search reaches the end of the list panel and it did not start from 0, it wraps around to the beginning, unless wrap-around is supplied as nil. The default value of wrap-around is t.

Example
(defun string-equal-prefix (string item)
  (let* ((start 0)
         (len (length item))
         (end (+ start (length string))))
    (and (>= len end )
         (string-equal string item 
                       :start2 start
                       :end2 end))))
 
(capi:contain
 (make-instance
  'capi:list-panel
  :items '("ae" "af" "bb" "cc")
  :keyboard-search-callback
  #'(lambda (pane string position)
      (capi:list-panel-search-with-function
       pane
       'string-equal-prefix ; or 'string-not-greaterp
       string
       :start position
       :reset-time 1
       :wrap-around t))))

Pressing "a" slowly cycles between "ae" and "af". Running the same example with string-not-greaterp instead causes "a" to cycle around all of the items.

See also

list-panel
set-list-panel-keyboard-search-reset-time
Searching by keyboard input


CAPI User Guide and Reference Manual (Macintosh version) - 3 Aug 2017

NextPrevUpTopContentsIndex