On Sep 19, 2010, at 6:36 PM, k...@highrolls.net wrote:
> So I thought I would draw the images as subclasses of NSImage in the tool 
> box.  Use mouseDown and mouseMoved to move them around the tool box.

 Did you perhaps mean NSImageView?

> Use drag and drop to go from the tool box to the layout and then mouseDown 
> and mouseMoved to reposition and reorient them in the layout.

 This may be a little awkward. You only get mouseDragged: etc. when the mouse 
is over your view, so if the user is dragging outside, you won't know where the 
mouse is (usually items dragged inside a canvas stop e.g. at the left edge of 
the canvas, but still follow up-and-down movements).

> Am I on the right track or is there something even easier?


 I think the best idea is probably to look at Apple's "Sketch" sample code, it 
is a little sample app available with full source code from Apple's web site. 
What it essentially does is create an NSObject subclass for each item that 
*has* an NSImage (or NSBezierPath or NSRect or whatever drawing primitive makes 
sense), not *is* a subclass of one. It then keeps a list of those and has the 
view draw them.

 However, if you want to draw *between* two views, or even from one window into 
another, you'll want to do the actual dragging using "drag and drop". This 
takes care of the actual moving of an image for you, but is a little more 
complicated because you need to come up with a way of attaching your NSObject 
subclass to the drag as a drag flavor (which can't take custom classes -- so I 
recommend you look into NSKeyedArchiver/NSKeyedUnarchiver to generate an NSData 
from your objects).

 I hope I've pointed you in the right general direction(s).

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to