Lisp HUG Maillist Archive

Q: How to scroll capi:list-panel just after displaying in LWW 4.4

Hello lispworkers,

I want to select an item from a list panel just after creating it. But I am
not able to make the panel scroll to the ensure the item to be visible.

(capi:define-interface test () ()
 (:panes
  (pane capi:list-panel
   :items (loop for i upfrom 0 below 100
                  collect (format nil "~d" i))
   :test-function 'string=
   ;:keep-selection-p t
   ;:initial-focus-item "66"
   :visible-min-height '(:character 20))))

(defmethod capi:interface-display :after ((face test))
  (with-slots (pane) face
    (setf (capi:choice-selection pane)
          (capi:search-for-item pane "66"))))

(setq face (capi:display (make-instance 'test))
      pane (slot-value face 'pane))

The item "66" really gets selected. Unfortunately, the initial scroll
position is on the top of the list, and the selected item is not visible.

Afterwards, evaluating
    (setf (capi:choice-selection pane)
       (capi:search-for-item pane "66")
in the Editor works fine.

Placing  (setf capi:choice-selection) in the :creation-callback does not
help. Any takers?

BTW, the :initial-focus-item initarg does not work it at all, must it?
--
Sincerely,
Dmitri Ivanov
www.ystok.ru


Re: Q: How to scroll capi:list-panel just after displaying in LWW 4.4

Dmitri Ivanov wrote:

>Hello lispworkers,
>
>I want to select an item from a list panel just after creating it. But I am
>not able to make the panel scroll to the ensure the item to be visible.
>
>(capi:define-interface test () ()
> (:panes
>  (pane capi:list-panel
>   :items (loop for i upfrom 0 below 100
>                  collect (format nil "~d" i))
>   :test-function 'string=
>   ;:keep-selection-p t
>   ;:initial-focus-item "66"
>   :visible-min-height '(:character 20))))
>
>(defmethod capi:interface-display :after ((face test))
>  (with-slots (pane) face
>    (setf (capi:choice-selection pane)
>          (capi:search-for-item pane "66"))))
>
>(setq face (capi:display (make-instance 'test))
>      pane (slot-value face 'pane))
>
>The item "66" really gets selected. Unfortunately, the initial scroll
>position is on the top of the list, and the selected item is not visible.
>
>Afterwards, evaluating
>    (setf (capi:choice-selection pane)
>       (capi:search-for-item pane "66")
>in the Editor works fine.
>
>Placing  (setf capi:choice-selection) in the :creation-callback does not
>help. Any takers?
>
>  
>
CL-USER 11 > (capi:scroll (slot-value face 'pane) :vertical :move 50)
NIL

http://www.lispworks.com/documentation/lw44/CAPRM/html/capiref-302.htm#pgfId-1580041

I suppose you will have to calculate the position of the selected item 
and set the scroll
accordingly.

Wade


Re: Q: How to scroll capi:list-panel just after displaying in LWW 4.4

This also works:

(capi:define-interface test ()
  ((initial-items
    :initform (loop for i upfrom 0 below 100
                    collect (write-to-string i))))
 (:panes
  (pane capi:list-panel
   :items initial-items
   :test-function #'string=
   :selected-item "66"
   :visible-min-height '(:character 20))))

Wade


Updated at: 2020-12-10 08:53 UTC