Lisp HUG Maillist Archive

tree-view expand and contract

If I use the '+' button in the example below, to (try to) expand all  
the nodes in the tree view, I have to press *twice* to get all the  
levels expaned. Strangely enough, this happens only after a new  
instance is created. After the first press the button(s) start to do  
the right thing, i.e., expand and contract all the nodes in the tree- 
view.

Am I applying 'tree-view-expanded-p' incorrectly somehow?

(capi:define-interface tree-view-test ()
   ()
   (:panes
    (tree capi:tree-view
          :roots '(1 2 3 4)
          :children-function #'(lambda (x)
                                 (and (< x 50)
                                      (let ((base (* x 4)))
                                        (list (+ base 1)
                                              (+ base 2)
                                              (+ base 3)
                                              (+ base 4)))))
          :visible-min-width 200
          :visible-min-height 200
        ;  :retain-expanded-nodes t
          :vertical-scroll t)
    (expand capi:push-button :text "+"
            :callback-type :interface
            :selection-callback #'(lambda (interface)
                                    (with-slots (tree) interface
                                      (capi:map-collection-items tree  
#'(lambda(x) (setf (capi::tree-view-expanded-p tree x) t))))))
    (contract capi:push-button :text "-"
              :callback-type :interface
              :selection-callback #'(lambda (interface)
                                      (with-slots (tree) interface
                                        (capi:map-collection-items  
tree #'(lambda(x) (setf (capi::tree-view-expanded-p tree x) ())))))))
   (:layouts
    (default-layout
     capi:column-layout
     '(tree expand contract)))
   (:default-initargs
    :title "Tree View Test"))

(capi:display (make-instance 'tree-view-test))


Mika

Mika Kuuskankare
Researcher
Department of Doctoral Studies in Musical Performance and Research
Sibelius Academy

Henkilökohtainen postiosoite/Personal post address
PL 342 - PO Box 342
FIN-00121 Helsinki, FINLAND
Tel: +358 (0)40 5415 233
Skype: mkuuskan
home page: www.siba.fi/~mkuuskan





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