[cells-gtk-devel] Editable Table

Martin Kielhorn kielhorn.martin at googlemail.com
Tue Oct 6 18:37:34 UTC 2009


Hi,
I want a table with numbers and when I click on one number I want to change
it to
a new value. I managed to copy the table from test-gtk/test-tree-view.lisp
and I added
:editable t to the def-columns call. I can edit the number, but the system
doesn't store
the value back into one of my variables, e.g. (position$ (nth 2 *items*)).
So when I press
enter after the edit, the old value will be shown again.

I hoped the :on-edit slot of listbox could be used for this task but the
format is never executed.

Or is it only possible to do it like in the Cells-Tree-View example?
It seemed quite complicated to me, as I don't want two copies of branched
trees.
I think that is the next thing I would be glad to hear how :on-edit is to be
used.

[I run the following code in sbcl with threads.]

(require :asdf)
(require :cells-gtk)

(defpackage :mk
  (:use :cells :cl :cells-gtk))

(in-package :mk)

(defmodel myapp (gtk-app)
  ()
  (:default-initargs :width 400 :height 300
             :md-name :mk-top
             :kids (c-in nil)))
(init-gtk)
(start-win 'myapp)

(defmodel listbox-test-item ()
  ((position  :accessor position$  :initarg :position  :initform nil)
   (curvature :accessor curvature$ :initarg :curvature :initform nil)))

(defparameter *items*
  (list (make-be 'listbox-test-item
             :position  (coerce (random 20) 'double-float)
             :curvature (coerce (random 20) 'double-float))
    (make-be 'listbox-test-item
             :position  (coerce (random 20) 'double-float)
             :curvature (coerce (random 20) 'double-float))))

(let ((top (find-widget :mk-top)))
  (setf
   (kids top)
   (list
    (mk-vbox
     :fm-parent top
     :kids
     (kids-list?
      (mk-listbox :md-name :listbox
          :selection-mode :single
          :columns (def-columns
                (:double (:title "Position") (lambda (node) '(:editable t)))
                (:double (:title "Curvature")))
          :items *items*
          :print-fn (lambda (item)
                  (list (position$ item)
                    (curvature$ item)))
          :on-edit (lambda (node col new-val)
                 (format t "~a~%" (list node col new-val)))))))))


Regards, Martin
-- 
Martin Kielhorn
Randall Division of Cell & Molecular Biophysics
King's College London, New Hunt's House
Guy's Campus, London SE1 1UL, U.K.
tel: +44 (0) 207 848 6519,  fax: +44 (0) 207 848 6435
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cells-gtk-devel/attachments/20091006/ffebe98a/attachment.html>


More information about the cells-gtk-devel mailing list