[plt-scheme] Proper way to close windows

From: Robby Findler (robby at cs.uchicago.edu)
Date: Thu Oct 6 12:56:12 EDT 2005

At Thu, 6 Oct 2005 10:40:28 -0600, Matthew Flatt wrote:
> It's more like Java, except that a few specific callbacks (such as the
> paint callback for a canvas%) can be supplied when constructing an
> instance.

Do note, however, that classes are values, so you can build your own
functions to make particular extensions simpler. For example:

(define (with-on-close proc super%)
  (class super%
    (define/augment (on-close)
      (inner (void) on-close))

(define (with-on-activate proc super%)
  (class super%
    (define/override (on-activate b)
      (super on-activate b)
      (proc b))

(define frame
  (new (with-on-close
        (lambda () (printf "closed\n"))
         (lambda (b) (when b (printf "activated\n")))
       (label "label")))

(send frame show #t)

You could even make these method's depend on some assignable context if
you wanted to go even further towards javascript, but you might start
to lose track of what your program is doing if you're not disciplined
about it. ...


Posted on the users mailing list.