Re: Question concerning mouseDragged events.
Re: Question concerning mouseDragged events.
- Subject: Re: Question concerning mouseDragged events.
- From: Jens Alfke <email@hidden>
- Date: Tue, 27 May 2008 20:48:15 -0700
On 27 May '08, at 8:38 PM, Graham Reitz wrote:
Do folks somehow get the direction of the drag, size of the
rectangle, starting x,y, and etc.?
IIRC, there are NSEvent properties that give you the x and y deltas
since the last mouseDragged event (called something like -dx or -
deltaX...)
More commonly, I store the coordinates of the mouse-down in an NSPoint
instance variable and use that while handling mouseDragged and
mouseUp. This is sort of an abuse of scope, because that information
is specific to the drag operation, not part of the object's state, but
it's safe because, as we all know, it's intuitively obvious that there
can only be one mouse drag happening at a time.
A cleaner design would be to create some kind of "MouseTracker" object
to store the state, and instantiate one on mouse-down and pass the
other mouse events to it. But I've never found it worth the trouble to
make one.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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