Re: Drag and drop color swatches
Re: Drag and drop color swatches
- Subject: Re: Drag and drop color swatches
- From: Christopher Drum <email@hidden>
- Date: Wed, 8 Dec 2004 09:13:13 -0800
On Dec 8, 2004, at 3:34 AM, Heinrich Giesen wrote:
NSColor *dragColor = [self color];
[pb declareTypes:[NSArray arrayWithObject:NSColorPboardType] owner:self];
[dragColor <x-tad-bigger>writeToPasteboard:pb</x-tad-bigger>];
You read a color from the pasteboard with:
<x-tad-bigger>color = [NSColor colorFromPasteboard:</x-tad-bigger><x-tad-bigger>pasteBoard];
</x-tad-bigger>
Well, this certainly explains a lot and works like a champ. The reason I was using the NSData and the NSArchiver was because of the documentation for NSPasteboard. Under the "Writing Data" methods, there is no "setColor:forType:" the same way there is a "setString:forType:" All that is listed is "setData:forType:" and the preceding docs mention NSColor data, so I took that to mean I had to wrap non-strings into NSData objects. I see now that I was focusing too heavily on the "data" part of those docs.
The reason I have the NSStringPboardType declared is because I want to drag swatches into text fields and have it put down some textual information.
Now that I understand this about NSColor, I have a better understanding of how to research such things in the future. Thank you.
------------------------------------------------------------------
Christopher Drum
http://homepage.mac.com/christopherdrum
Check out FileWrangler, my five-star rated (MacUpdate, VersionTracker) Cocoa app written in Objective-C for the batch renaming of files.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden