[ltk-user] Set xscrollcommand to a lisp function
Vitaŭt Bajaryn
vitaut.bayaryn at gmail.com
Mon Jun 4 17:29:51 UTC 2012
On 4 June 2012 19:30, Vitaŭt Bajaryn <vitaut.bayaryn at gmail.com> wrote:
> On 2 June 2012 21:04, Vitaŭt Bajaryn <vitaut.bayaryn at gmail.com> wrote:
>>
>> How can I set :xscrollcommand configure option to a lisp function?
>
> I figured I can do something like that:
> ;;;;
> (in-package #:ltk)
>
> (defun (setf x-scroll-command) (fun widget)
> (let ((name (create-name)))
> (add-callback name fun)
> (format-wish "~a configure -xscrollcommand {callback ~a}"
> (widget-path widget) name)))
> (export 'x-scroll-command)
> ;;;;
> But callback needs additional parameters and I don't know how to call
> a function in tcl.
I solved this question. Maybe make (setf x-scroll-command) a part of
ltk? Maybe someone except me would want to call a function when a
widget is scrolled.
;;;;
(in-package #:ltk)
(eval-when (:load-toplevel)
(setf *init-wish-hook*
(append *init-wish-hook*
(list
(lambda ()
(send-wish
"proc callback2val {s val1 val2} {global server; puts $server
\"(:callback \\\"$s\\\" $val1 $val2)\"} "))))))
(defun (setf x-scroll-command) (fun widget)
(let ((name (create-name)))
(add-callback name fun)
(format-wish "~a configure -xscrollcommand {callback2val ~a}"
(widget-path widget) name)))
(export 'x-scroll-command)
;;;;
More information about the ltk-user
mailing list