From a56b3bff6180f3acb5a6cf81538975fc82b20aa9 Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Mon, 25 Aug 2008 13:30:51 +0000 Subject: [PATCH] mouse events in [0,WIDTH] x [0,HEIGHT] svn: r11413 --- collects/htdp/world.ss | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/collects/htdp/world.ss b/collects/htdp/world.ss index 322a6e4193..cdb15d3441 100644 --- a/collects/htdp/world.ss +++ b/collects/htdp/world.ss @@ -635,11 +635,16 @@ Matthew (define (set-and-show-frame w h animated-gif) (define the-play-back-custodian (make-custodian)) (define frame (create-frame the-play-back-custodian)) + (set! WIDTH w) + (set! HEIGHT h) (when animated-gif (add-stop-and-image-buttons frame the-play-back-custodian)) (add-editor-canvas frame visible-world w h) (send frame show #t)) +(define WIDTH 0) +(define HEIGHT 0) + ;; [Box (union false Thread)] -> Frame ;; create a frame that shuts down the custodian on close (define (create-frame the-play-back-custodian) @@ -902,13 +907,14 @@ Matthew (parameterize ([current-eventspace evt-space]) (queue-callback (lambda () - (with-handlers ([exn:break? break-handler][exn? exn-handler]) - (define x (- (send e get-x) INSET)) - (define y (- (send e get-y) INSET)) - (define m (mouse-event->symbol e)) - (set! the-world (f the-world x y m)) - (add-event MOUSE x y m) - (redraw-callback)))))) + (define x (- (send e get-x) INSET)) + (define y (- (send e get-y) INSET)) + (define m (mouse-event->symbol e)) + (when (and (<= 0 x WIDTH) (<= 0 y HEIGHT)) + (with-handlers ([exn:break? break-handler][exn? exn-handler]) + (set! the-world (f the-world x y m)) + (add-event MOUSE x y m) + (redraw-callback))))))) ;; MouseEvent -> MouseEventType (define (mouse-event->symbol e)