[plt-scheme] Problem for asking "are you sure?" before closing a frame

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Apr 19 10:22:40 EDT 2008

At Wed, 16 Apr 2008 23:58:32 -0700 (PDT), AntoinePaulSoulé wrote:
> Hi!
> I have written
> (define diagram-frame%
>   (class frame% ()
>      (define/augment (on-close)
>          (send this show #t)
>          (send QUIT-FRAME show #t))
>   (super-new)))
> 
> QUIT-FRAME is a frame which ask "are you sure you want to qui?" with
> buttons "yes" and "no", and after "Do you like to save your document?"
> My problem is that my diagram-frame disappear when I click on the
> window close button at the top, in the same time that my QUIT-FRAME
> appear. I have tried (send this show #t) like you can see but it
> doesn't work. I would like to say at my diagram-frame "wait the answer
> before closing or not!!!!".

You should augment `can-close?' instead of `on-close'.

The `on-close' method is called after the decision is made to close the
frame; the frame is closed after `on-close' returns. But `can-close?'
is called first, and it determines whether the frame will be closed
(and whether `on-close' methods will be called as a result).

Matthew



Posted on the users mailing list.