[racket] drag events on a canvas

From: Marijn (hkBst at gentoo.org)
Date: Mon Sep 5 10:24:38 EDT 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,

the following program defines a canvas%-derived that catches mouse
events and prints the drag events. Unfortunately I was unable to make
it report any drag events. It does report motion events and left-click
events when generated by me (currently turned off). Is this a bug or
am I doing something wrong here?

Marijn


#lang racket/gui

(define (handle-drag event)
  (print event))

(define (handle-motion event)
  #f)

(define (handle-left-down event)
  #f #;(print event))

(define drawtest%
  (class canvas%
    (init parent)
    (super-new (parent parent))

    (define/override (on-event event)
      (let ((type (send event get-event-type)))
        (case type
          ((motion)
           (if (send event button-down?)
               (handle-drag event)
               (handle-motion event)))
          ((left-down)
           (handle-left-down event))  )))

    ))

(define root (new frame% (label "Draw Test")))

(new drawtest%
     (parent root)
     (min-width 100) (min-height 100)
     (style '(border) #;'(combo control-border)))

(send root show #t)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5k26YACgkQp/VmCx0OL2zsvgCfbRwmpapGh1EL3AdL+8SN7DV+
sYcAoI81YwOnJN7R03PpJt+IyH95h3Vu
=Zx+r
-----END PGP SIGNATURE-----


Posted on the users mailing list.