[plt-scheme] Found: maintainable solution to non-standard callbacks

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Wed Dec 20 18:38:03 EST 2006

originally I was woried that my solution would have maintainability problems
as it wouldnt be able to be refactored into guibuilder objects.  However I
find a way to do it, basically it's creating a new frame class which
inherits from frame%, and were calling the new class frame%.  This could
then be refactored into callback registration methods, and a new module "
mred-plus-right-mouse-clicks.ss" which would provide the mred language, with
mred:frame% repaced with our new frame%.

(define (test)
  (let* ((object-registry #f)
    (class frame%
      (override on-subwindow-event)
      (define on-subwindow-event
        (lambda (reciever event)
          (if (equal? 'right-down (send event get-event-type))
                (display #\newline)
                (display "you clicked the right button on ")
                (display reciever)
                (if (equal? (first (first object-registry)) reciever)
                    (display "AND IT'S BUTTON393!!!"))
                ;if we don't actually do anything, pass this on....
                ;(super on-subwindow-event reciever event)
              (super on-subwindow-event reciever event))))

{{gui goes here}}

    (set! object-registry (list (list button393 `do-something)))
    (send top show #t)))


((lambda (y) (y y)) (lambda (y) (y y)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20061220/fa13a7e9/attachment.html>

Posted on the users mailing list.