Re: The mouse is where, again?
Re: The mouse is where, again?
- Subject: Re: The mouse is where, again?
- From: "Clark Cox" <email@hidden>
- Date: Mon, 28 Jan 2008 10:24:21 -0800
On Jan 28, 2008 9:51 AM, Jayson Adams <email@hidden> wrote:
>
> On Jan 27, 2008, at 11:46 PM, Quincey Morris wrote:
>
> > Let me lay the example out a bit more specifically, and see if I
> > can change your mind.
> >
> > Suppose (for simplicity) the mouse happens to be moving smoothly
> > along the 45-degree diagonal. So it starts at (0,0) and moves
> > through (50,50) and (100,100) and (200,200) and so on.
> >
> > Suppose that the mouse-down is at (0,0), and the mouse-up is at
> > (200,200).
> >
> > Now imagine the state of the application in the middle of the
> > dragging sequence, at a moment when it's still processing a mouse-
> > moved event whose location is (100,100).
> >
> > It's entirely possible (see below for more about this) that while
> > this event is being processed in the body of your while loop,
> > there's *already* another event in the queue -- in particular, the
> > mouse-up at (200,200).
> >
> > It's *also* entirely possible that at the same moment, while the
> > same mouse-moved (100,100) event is being processed, the mouse
> > itself is *already* (in real-time) at (300,300).
> >
> > In these circumstances, would it be correct or incorrect to extend
> > to (300,300) a selection rect being dragged out?
>
> Obviously incorrect, and this error would not occur with the code
> snippet I provided.
I hate to break it to you, but it most certainly will, for exactly the
reasons that Quincy stated. If the mouse is moving quickly enough (or
the computer is moving slowly enough), your code will be reading the
wrong location of the mouse, and can see the mouse move *after* the
mouseUp has been posted to the queue, but still think the mouse is
down.
--
Clark S. Cox III
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden