• 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: Drag image of NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drag image of NSView


  • Subject: Re: Drag image of NSView
  • From: John Pannell <email@hidden>
  • Date: Fri, 14 Oct 2005 21:35:21 -0600

Hi Ken-

The example code (assuming you pulled this from the NSView docs) only addresses the case where the object being dragged is an actual image (i.e. the contents of an NSImageView or cell). There is no method on NSView that will return an image looking like the view.

Actually, if you are Tiger only, NSView has a method (bitmapImageRepForCachingDisplayInRect:) that would fit the bill - you could pass the rect for the whole view and then construct an NSImage from the NSBitmapImageRep returned.

Note that this would send the message that the user is dragging the entire view somewhere, which is not appropriate for frequently used compound views (NSMatrix, NSTableView, etc.) A more common pattern would have users dragging the data represented by a cell of one of these views, and cells with images have methods to pull the image from them. Not knowing your specific situation, I can't comment much further.

I just got done implementing drag and drop in my app, feel free to mail off-list with more specifics if you would like and I'd be happy to assist if I can.

HTH!

John

John Pannell
Positive Spin Media
http://www.positivespinmedia.com

On Oct 14, 2005, at 8:59 PM, Ken Tozier wrote:

I'm sure this is an easy one but the Apple Drag and Drop info located here "http://developer.apple.com/documentation/Cocoa/ Conceptual/DragandDrop/index.html?http://developer.apple.com/ documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html" gives no indication of how to actually create a transparent snapshot of an NSView for use as a drag image.

The documentation for NSView's dragImage:at:offset:event:pasteboard:source:slideBack: method shows the following snippet for getting the image

[pboard setData:[[self image] TIFFRepresentation] forType:NSTIFFPboardType];
[self dragImage:[self image] at:[self imageLocation] offset:dragOffset event:theEvent pasteboard:pboard source:self slideBack:YES];


Problem is though, NSView has no "image" method. Nor do it's superclasses "NSResponder" or "NSObject" so where are they getting the image? Is this some deprecated method of NSView?

Anyway. If there is some better documentation around or if someone could provide a simple code snippet of how to get a transparent image of a view for a drag icon, it would be much appreciated

Thanks for any help

Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40positivespinmedia.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Drag image of NSView
      • From: Ryan Britton <email@hidden>
References: 
 >Drag image of NSView (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: First-Time Help Needed: Instantiating a Subclass in IB
  • Next by Date: Re: Drag image of NSView
  • Previous by thread: Drag image of NSView
  • Next by thread: Re: Drag image of NSView
  • Index(es):
    • Date
    • Thread