[plt-scheme] Please, help me out

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Oct 7 12:22:00 EDT 2002

At Mon, 30 Sep 2002 23:21:41 -0500, "Yamil Salim Perchy Bocanegra" wrote:
> The first one is that how i can make a canvas that takes events from my 
> controller pad, or as you know it "the game port", i've been looking all 
> over internet and i found nothing, as you can see this isn't a homework, i'm 
> really interested on programming games.

That might be possible, and it may depend on the OS. Which OS do you

For example, in Windows, you may be able to open "COM3" to talk to the
controller. (That's a wild guess.)

> The second one is that when i switched drom drschem ver.103 to drscheme 
> ver.203 my canvas that recieved keyboard events doesn't work anymore, it 
> tells me that the override function is not a pair of identifiers, the code 
> is as follows:
> (define f (make-object frame% "frame" #f 300 300 20 20))
> (define my-canvas%
>   (class canvas% (frame)
>     (override
>       [on-char (lambda (event) (display (send event get-key-code)))])
>     (sequence (super-init f))))
> (define s (make-object my-canvas% f))
> (send f show #t)

The class system changed quite a bit between versions 103 and 200. The
above code might translate as

 ;; untested!
 (define my-canvas%
   (class canvas%
     (init frame)
     (define/override on-char
       (lambda (event) (display (send event get-key-code))))
     (super-init frame))))

Or you can use the `class100' compatibility form:

 ;; not tested, either!
 (require (lib "class100.ss"))
 (define my-canvas%
   (class100 canvas% (frame)
     ;   ^^^
       [on-char (lambda (event) (display (send event get-key-code)))])
     (sequence (super-init f))))


Posted on the users mailing list.