Re: Capturing portion of an NSView for drag-and-drop image
Re: Capturing portion of an NSView for drag-and-drop image
- Subject: Re: Capturing portion of an NSView for drag-and-drop image
- From: Chuck Pisula <email@hidden>
- Date: Fri, 18 May 2001 13:45:00 -0700
Try locking focus on the view where you have already drawn the cell, and
using [[NSBitmapImageRep alloc] initWithFocusedViewRect:r], where r is
the part of the view you want the bits for.
-chuck
On Friday, May 18, 2001, at 09:34 AM, Brad Werth wrote:
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
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev