[racket] Can I capture the mouse events of canvas% without sub-classing?
At Sat, 30 Nov 2013 08:18:59 +1100, Daniel Prager wrote:
> Am I right in thinking that while you can add a callback to respond
> the on-paint event of canvas% at construction time, i.e..
>
> (new canvas% ...
> [paint-callback (lambda (c e) ...)])
>
> to respond to other events -- mouse, keyboard, etc. -- it is necessary to
> sub-class?
>
> E.g.
>
> (define my-canvas%
> (class canvas%
> (define/override (on-event ev)
> (when (send ev button-down? 'left)
> ; do something
> (super-new)))
>
> Or are there alternatives?
No, that's the only way, currently.