[plt-scheme] Question about callbacks

From: Robert Bruce Findler (robby at cs.uchicago.edu)
Date: Sun Dec 8 08:52:57 EST 2002

The exit callback is for when all of your frames close, and it only
works if you are using the framework classes (ie, frame:basic% or
something like that) -- it doesn't work when you use frame%.

To test the closing of just one frame, you should create a derived
class from frame%:

 (define my-frame%
   (class frame%
     (define/override (on-close) ...)
     (define/override (can-close?) ...)
     (super-instantiate ())))

where you fill in the ellipses with whatever you want (see the docs on
those methods for details).

If you are overriding those methods on some derived class, be sure to
call the super method:

 (define my-frame%
   (class frame:basic%
     (rename [super-on-close on-close])
     (define/override (on-close) 
       	(super-on-close)
        ...)
     (super-instantiate ())))

Hope that helps.

Robby

At Sun, 8 Dec 2002 00:48:49 -0800 (PST), Yuri Niyazov wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> Hello all, newbie here, please forgive.
> 
> Having the following problem: figuring out how the windowing system works. 
> Used the examples to do the following:
> 
> (define frame (instantiate frame% ("Drawing Example") (width 300) (height 300)))
> (define canvas (instantiate canvas% (frame) (paint-callback mypaint) ) )
> 
> and in mypaint I do all sorts of device context stuff.
> 
> So, I haven't been able to figure out how to install a "close" callback - that is, when 
> someone
> hits alt-f4 on that screen in windows. Is this not possible, or am I missing something 
> completely
> obvious? I haven't been able to figure out how exit:insert-on-callback works, but it 
> doesn't seem
> to be what I need, because if I understand it correctly, it works when you exit out the
> application, not when you hit close on a frame.



Posted on the users mailing list.