ADC Home > Reference Library > Technical Q&As > Cocoa > Interapplication Communication >

How to set a custom drag image when doing an HFS Promise drag in Cocoa


Q: How do you set a custom drag image when doing an HFS Promise drag in Cocoa?

A: NSView's method -dragPromisedFilesOfTypes:fromRect:source:slideBack:event: doesn't provide a way to set the drag image to be used when dragging an HFS promise file. However, this method calls another NSView method, -dragImage:at:offset:event:pastboard:source:slideback: in its implementation, which does provide a parameter for an NSImage to be used as the drag image. So, to set a custom drag image, simply override -dragImage:at:offset:event:pastboard:source:slideback: , setup your custom image, call super's -dragImage:at:offset:event:pastboard:source:slideback: and pass in your custom drag image.


[Sep 15, 2003]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.