[plt-scheme] Proper way to close windows

From: Dale Hurtt (dhurtt at sprintmail.com)
Date: Thu Oct 6 12:05:57 EDT 2005

I have noticed that if I simply click the Close icon on a frame% instance (which is an mdi-child), I lose the ability to use the Alt key to select menus. Looking through the documentation, it seems like clicking the Close icon only turns the window's visibility to #f. Is that correct?

Is so, what is the proper way to actually dispose of a window? Assuming I have a File->Close menu item:

; Define the File->Close menu item and attach it to the File menu.
(define file-close-menu-item
  (instantiate menu-item%
    ("&Close")
    (parent file-menu)
    (callback
     (lambda (item event)
       ()))))

If I have a reference to the window to be disposed in document-window, what would the correct call be to close that window in the callback?

Also, if I want to react to an event, is it more like JavaScript or like Java? In JavaScript, I would simply add a function to the event property, like so:

window.onload = function () { doSomething (): }

Whereas with Java, I would need to sub-class the window and override the appropriate methods:

public class MyWindow extends Window {
  private void paint (e graphics) {
  }
}

(Okay, so that is not the appropriate Java code. Considering this is a Scheme board...)

Do I have to sub-class in order to add my own event handlers to an object instance, as shown in the canvas% example in the MrEd manual? Or is there an easier JavaScript style way?

TIA,

Dale


Posted on the users mailing list.