• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question concerning mouseDragged events.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Question concerning mouseDragged events.
      • From: Graham Reitz <email@hidden>
References: 
 >Re: How hard is it to learn Cocoa - Survey ? (From: Gregory Weston <email@hidden>)
 >Question concerning mouseDragged events. (From: Graham Reitz <email@hidden>)

  • Prev by Date: Re: Question concerning mouseDragged events.
  • Next by Date: Re: if statement
  • Previous by thread: Re: Question concerning mouseDragged events.
  • Next by thread: Re: Question concerning mouseDragged events.
  • Index(es):
    • Date
    • Thread