[plt-scheme] MrEd: strange mouse-event% behavior

From: Tord Svensson (tord at lysator.liu.se)
Date: Fri Jul 23 07:36:09 EDT 2004

Hi,

I'm using DrScheme 206 on Mac OS X 10.3 and have encountered some strange
behavior with regard to mouse-events.

1. A mouse motion event (with dragging = #t) is generated after every
mouse down even if the mouse haven't been moved.

Is there a rational behind this behavior or is it perhaps a bug?

2. If you change the origin of the dc object associated with the
component generating the events, the coordinates of the mouse down event
differs from the mouse-motion and mouse-up event (even if you haven't
moved the mouse). If set-origin is called with say 50 50, you get the
following behavior:

down: 109, 93
motion: 59, 43 dragging? #t
up: 59, 43

That is, the mouse motion and mouse up events take the change of origin
into account but the mouse down doesn't. This also looks like a bug to me
but perhaps there is more to it (or have I missed something)?

Anyway, here is the code I used to test both of the above cases:

(module some-module
  mzscheme

  (require (lib "class.ss")
           (lib "mred.ss" "mred"))

  (provide (all-defined))

  (define weird-mouse-events-canvas%
    (class canvas%
      (init-field parent)

      (define/public (set-offset x y)
        (send (send this get-dc) set-origin x y))

      (define (display*ln . args)
        (for-each display args)
        (newline))

      (define/override (on-event event)
        (let ((x (send event get-x))
              (y (send event get-y)))
          (case (send event get-event-type)
            ((left-down) (display*ln "down: " x ", " y))
            ((left-up)   (display*ln "up: " x ", " y))
            ((motion)    (display*ln "motion: " x ", " y
                                     " dragging? "
                                     (send event dragging?))))))

      (super-instantiate (parent))))

  (define main (instantiate frame% ("some frame")
                 (min-width 200) (min-height 200)))

  (define canvas (instantiate weird-mouse-events-canvas% ()
                              (parent main)))
  (send canvas set-offset 50 50)
  (send main show #t))


Please cc me when you reply as I only subscribe to the digest version of
the mailing list.

Cheers

--Tord


Posted on the users mailing list.