[cells-devel] Re: Celtk contrib: ttk::treeview
Madhu
enometh at meer.net
Sun Sep 28 15:06:02 UTC 2008
* Kenny Tilton <48DEA802.1050303 at optonline.net> :
Wrote on Sat, 27 Sep 2008 17:39:14 -0400:
| Can't you just have:
|
| :on-open (lambda (self) (setf (openp self) t))
|
| And have a kids rule:
| (c? (when (^openp)...))
|
| From the code it looks like you understand this. Maybe you ran into an
| issue?
The issue was that I could not figure out how to limit expansions down
the tree using a kids rule at make-instance time. The general idea was
directories should be expanded only when needed. [Further I was using
`expandedp' to ensure that directories got expanded only once, even if
they were opened multiple times by on-open events]. I couldn't combine
these requirements with the desired initial state.
Besides, this was supposed to demo the idea that the tree represented in
the family's hierarchical model is directly displayed by the widget. So
manipulating the model (adding kids, sorting the kids) should reflect in
the displayed tree.
Anyway I figured out how to initalize kids the way I wanted: Don't do it
in the defmodel form (you cant get hold of a parent object there), just
do it in make-tk-instance. FWIW I'm attaching the current version.
There may be an outstanding bug around openp.
BTW, there is a problem with tk-format: if youre passing strings with ~,
FORMAT will barf on strange directives. Dirty workaround:
(defmethod tk-send-value :around ((s string))
(sanitize-string-for-format (call-next-method)))
(defun sanitize-string-for-format (string)
(let ((n (count #\~ string)))
(if (zerop n)
string
(let ((ret (make-string (+ n (length string))
:element-type (type-of (char string 0))))
(i -1))
(loop for c across string
do (setf (aref ret (incf i)) c)
if (eql c #\~) do (setf (aref ret (incf i)) c))
ret))))
--
Regards
Madhu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dirtree-test.lisp
Type: text/x-emacs-lisp
Size: 3302 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cells-devel/attachments/20080928/59752e93/attachment.bin>
More information about the cells-devel
mailing list