Draggable NSImage of custom NSView ???
Draggable NSImage of custom NSView ???
- Subject: Draggable NSImage of custom NSView ???
- From: Robert Miller <email@hidden>
- Date: Thu, 17 Jan 2002 09:31:27 -0500
- Organization: RFM & Associates
Hello fellow Cocoans,
This is probably in the realm of Cocoa 101 but.... I'm trying to
obtain a drag image of a custom view and its subviews by first creating
an NSImage that is the same size as my custom view, locking focus on the
NSImage, and drawing my custom view using its display method ex.
- (NSImage*) makeMyDragImage
{
NSImage *dragImg = [[NSImage alloc] initWithSize:[self frame].size];
[dragImg lockFocus];
[self display];
[dragImg unlockFocus];
return dragImg;
}
of course the image is always empty and nothing gets drawn into it
probably because the display call unfocuses the image and focuses
'self'. So that's the $64,000.00 question. How do I draw my custom view
and its subviews into an NSImage so that I can obtain a draggable image
representing the view. (Similar to dragging a build phase segment in PB)
???? PS. I've also tried NSCopyBits using [self gState] as the argument
in place of calling display and that has no effect either ???
Thanks in advance for any help,
Regards,
Bob M.