Erick Gallesio <eg_at_unice.fr> writes:
> David Fox writes:
> > If you add the following binding to the end of Demos/browse.stk you
> > get a "Goodbye" message when you hit the "Quit" button:
> >
> > (bind .f.list "<Destroy>"
> > (lambda () (format (current-error-port) "Goodbye~%")))
> >
> > However, if you add a window parameter you will get an error:
> >
> > (bind .f.list "<Destroy>"
> > (lambda (|W|) (format (current-error-port) "Goodbye~%")))
> >
> >
> > *** Background error:
> > unbound variable: .f.list
> >
> > #### WARNING: error occurred while executing the body of report-error!!
> > [...]
> >
> > Please help!
>
> This is not a bug but rather a Tk feature. In fact, the object is
> destroyed and AFTER that the binding is execute. The Tcl/Tk example
> below exemplifies this:
> button .b -text
> pack .b
> bind .b <Destroy> {%W configure -bg red}
> destroy .b
> will lead to an ``invalid command name ".b"'' message
>
> The only way I know to capture such an event is to use the
> "WM_DELETE_WINDOW" protocol of the toplevel which contains
> the widget. Something like:
>
> (button '.b :text "foo")
> (pack .b)
> (wm 'protocol *root* "WM_DELETE_WINDOW"
> (lambda ()
> (display "Hello\n")
> ; eventually destroy the window. Since this will not
> ; be done now that we have set the delete window
> ; protocol
> ))
>
> Hope it helps
I see. I think the problem was that I was converting TCL code to
Scheme and in TCL the window variable doesn't get evaluated. Or
something like that. Thanks!
--
David Fox http://hci.ucsd.edu/dsf xoF divaD
UCSD HCI Lab baL ICH DSCU
Received on Sun Feb 28 1999 - 00:38:48 CET