• 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: NSView and array of moveable NSImages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSView and array of moveable NSImages
      • From: "I. Savant" <email@hidden>
References: 
 >NSView and array of moveable NSImages (From: "Fen Soares" <email@hidden>)

  • Prev by Date: Re: Core Data and Views
  • Next by Date: Re: NSView and array of moveable NSImages
  • Previous by thread: NSView and array of moveable NSImages
  • Next by thread: Re: NSView and array of moveable NSImages
  • Index(es):
    • Date
    • Thread