Lisp HUG Maillist Archive

Q: How update the display of tabs in capi:tab-layout?

Hello lispworkers,

Is it possible to change the display of items in a tab-layout?
I would like to force the print-function of the tab-layout
to be called and return the strings different from the original.

IMHO, capi:choice-update-item should do that but it does not on LWW 4.6.

Below is the code snippet.

(capi:define-interface test-tabs ()
((suffix :initform ""))
(:panes
  (a capi:text-input-pane :title "A" :text "111")
  (b capi:text-input-pane :title "B" :text "222"))
(:layouts
  (tab-layout capi:tab-layout ()
   :items '(a b)
   :visible-child-function nil
   :print-function (lambda (item)
              (format nil "~a-~a" item suffix))
   :callback-type :interface-data
   :selection-callback 'tab-on-select)))

(defun tab-on-select (interface item)
  (with-slots (tab-layout) interface
    (setf (capi:choice-selected-item tab-layout)
           item
          (capi:tab-layout-visible-child tab-layout)
          (slot-value interface item))))

(setq face (capi:display (make-instance 'test-tabs)))

(setf (slot-value face 'suffix) "suffix")

; does not update the display of tabs
(capi:execute-with-interface face
  #'capi:choice-update-item
  (slot-value face 'tab-layout) 'a)

; does work but a bit brutal
(capi:execute-with-interface face
  (lambda (tab-layout)
    (let ((items (capi:collection-items tab-layout)))
      (setf (capi:collection-items tab-layout) nil
            (capi:collection-items tab-layout) items)))
  (slot-value face 'tab-layout))
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru


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