Capturing portion of an NSView for drag-and-drop image
Capturing portion of an NSView for drag-and-drop image
- Subject: Capturing portion of an NSView for drag-and-drop image
- From: Brad Werth <email@hidden>
- Date: Fri, 18 May 2001 09:34:32 -0700
- Organization: ORCAS, Inc.
I'm trying to implement drag-and-drop functionality between two
NSMatrixes. I would like to take a "snapshot" of the visual state of a
NSCell to use as the dragging image. I couldn't find a way to just get
an NSImage * from anything, but it seemed like one of the following
methods of NSView would do it for me:
- (NSData *)dataWithEPSInsideRect:(NSRect)aRect
or
- (NSData *)dataWithPDFInsideRect:(NSRect)aRect
I tried them both and they both failed differently. The PDF version
complained when the message was sent and the resulting image contained
only a portion of the border of the NSCell I was trying to capture, but
it was the correct size. The EPS version didn't complain, but the
resulting data couldn't be parsed correctly as EPS. Not certain why --
I wrote it out to a file to look at it (TextView was the only thing I
could find that would open it). All I noticed is that the header did
NOT contain the "%%BoundingBox:" comment that NSEPSImageRep says is
necessary to parse the data. What gives?
Anyway, I'm almost certain that I'm doing this the hard way, and was
hoping that anyone who has written something to do screen capture could
help me out.
Thanks,
Brad Werth
email@hidden