Re: destroy bug?

From: Erick Gallesio <eg_at_kaolin.unice.fr>
Date: Fri, 14 Jun 1996 13:54:31 +0100

> Jonathan Berry writes
> ;
> ; bug in destroy?
> ; *t* has 3 children, each of which should be able to kill it.
> ; only l can without generating an error.
> ; (3.0b2) -Jon
> ;
> (define *t* (make <toplevel>))
>
> (define l (make <label> :parent *t* :text "hi"))
> (define e (make <entry> :parent *t* :value "hi"))
> (define b (make <listbox> :parent *t* :value '("hi")))
> (pack l e b) ; tried switch order
>
> (display (eid l)) (newline)
> (display (eid e)) (newline)
> (display (eid b)) (newline)
>
> (bind l "<Double-1>" (lambda() (destroy *t*))) ; works
> (bind e "<Double-1>" (lambda() (destroy *t*))) ; error
> (bind b "<Double-1>" (lambda() (destroy *t*))) ; error
>
This is not really a bug (and not really a feature too :) but a nasty
consequence of the Tk4.0 bindings. In fact entries and listboxees have a
handler whixh is associed to clicking the mouse button for adjusting the
selection (labels ignore this event). When you double-1, the evnt mechanism
will call your script and AFTER the class script, which fails since there
 is no more a widget for treatting the event. Two solutions are available her:
        - Use the bindtags command (see Tk manual page for it)
        - Terminate the script with 'break to avoid the class binding execution
          i.e. you have to so something like:
                (bind l "<Double-1>" (lambda()
                                        (destroy *t*)
                                        ;; Don't launch the general binding
                                        'break)))

Hope it helps.




                -- Erick
Received on Fri Jun 14 1996 - 13:54:32 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST