views:

122

answers:

1

I am writing a tic-tac-toe game in plt-scheme as my AI course project. The idea for gui is a grid with 9 boxes, each with a canvas, using panes ... When the user click on a canvas, 'X' or 'O' will be drawn accordingly ...

The question is how can I catch mouse click event on canvas? I found out I need to use on-event, but still don't know how? Any clues?

+2  A: 

Ok, I got it ...

(define canvas-box%
  (class canvas%
    (define/override (on-event e)
           (when (equal? (send e get-event-type) 'left-down) (foobar-callback)))
    (super-new)))
Thura