Re: NSView and array of moveable NSImages
Re: NSView and array of moveable NSImages
- Subject: Re: NSView and array of moveable NSImages
- From: Scott Anguish <email@hidden>
- Date: Thu, 5 Apr 2007 15:49:56 -0400
On Apr 5, 2007, at 3:01 PM, Fen Soares wrote:
Therefore, I have an NSView into which I am drawing an array of
NSImages. I
would like to be able to move them around by dragging the mouse,
but feel as
though extensive mouse and z-index visibility testing is overkill,
but after
a good deal of surfing cannot see an alternative.
Is there a well trodden path to maintaining this sprite-like
behaviour in
Cocoa?
Absolutely.
You have a single view that displays all the items. and you track the
image rectangles, draw them, and do the hit-testing and dragging
yourself.
There isn't much extensive to it. You simply start at the closest
rectangle and test the bounds against the mouse location. First hit
is the one that you drag.
Have a look at the Views Programming Guide for Cocoa. it has an
example that does just this (although with a single rectangle, but
that is easy to extend)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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