Vitaŭt Bajaryn | 2 Jun 2012 20:04
Picon

Set xscrollcommand to a lisp function

How can I set :xscrollcommand configure option to a lisp function?

<div><p>How can I set :xscrollcommand configure option to a lisp function?<br></p></div>
Vitaŭt Bajaryn | 4 Jun 2012 18:30
Picon

Re: Set xscrollcommand to a lisp function

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.

_______________________________________________
ltk-user site list
ltk-user <at> common-lisp.net
http://common-lisp.net/mailman/listinfo/ltk-user
Vitaŭt Bajaryn | 4 Jun 2012 19:29
Picon

Re: Set xscrollcommand to a lisp function

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)
;;;;

_______________________________________________
ltk-user site list
ltk-user <at> common-lisp.net
http://common-lisp.net/mailman/listinfo/ltk-user
cage | 4 Jun 2012 21:59

Re: Set xscrollcommand to a lisp function

On Mon, Jun 04, 2012 at 08:29:51PM +0300, Vitaŭt Bajaryn wrote:

[...]

> 
> I solved this question. Maybe make (setf x-scroll-command) a part of
> ltk?

IMHO this would be a good idea!

C.

_______________________________________________
ltk-user site list
ltk-user <at> common-lisp.net
http://common-lisp.net/mailman/listinfo/ltk-user

Gmane