#30 get_motion_events always returning []

closed-fixed
nobody
None
5
2009-04-11
2009-03-28
No

the draw example unfortunately doesn't do line-drawing because on mouse-down, motion events always returns an empty list. this is on an amd64 system, debian/testing.

Discussion

  • Luke Kenneth Casson Leighton

    also tested on x86 system: same fault.

     
  • Luke Kenneth Casson Leighton

    ok changed draw.py example to this, and despite events being empty, the example now works

    events = self.win.window.get_motion_events(self.time, ev.time)

    # Record the previous last coordinate, and append
    # the new coordinates

    firstline = len(self.lines) - 1

    # Discard the first coordinate if that is identical to
    # the last recorded coordinate

    if events:

    pos = events[0]
    if (pos.x, pos.y) == self.lines[-1]:
    events = events[1:]

    # Append all coordinates
    for pos in events:
    x = pos.x

     
  • Peter Liljenberg

    This turns out to be a bug in the example programs: they should add a line to the MotionNotify event coordinate, even if get_motion_events() return no intermediate pointer positions. Fix for this checked into SVN now.

    When these programs were written back in 2000, it seems that computers weren't fast enough to generate a MotionNotify event for each new coordinate and thus get_motion_events() always had some intermediate positions to return too. Nowadays there seems to be an event for each new coordinate, triggering this old bug. I feel a bit old now.

     
  • Peter Liljenberg

    • status: open --> closed-fixed
     
  • Peter Liljenberg

    Oh, I missed lkd's comment that said the same thing. Now I feel old and silly.

     

Log in to post a comment.