• 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
Draggable NSImage of custom NSView ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Draggable NSImage of custom NSView ???
      • From: Carlos Weber <email@hidden>
    • Re: Draggable NSImage of custom NSView ???
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: Looping sound with NSSound
  • Next by Date: PushButton problems
  • Previous by thread: SOUND RECORDING !?
  • Next by thread: Re: Draggable NSImage of custom NSView ???
  • Index(es):
    • Date
    • Thread