Drag and drop color swatches
Drag and drop color swatches
- Subject: Drag and drop color swatches
- From: Christopher Drum <email@hidden>
- Date: Tue, 7 Dec 2004 22:01:51 -0800
Hi everyone,
New to the developer mailing list, but excited to get to know everyone. Running into an issue with a little tool I'm developing. Hope someone can shed some light on things for me.
I have a color picker app I've built. Works just great, can drag and drop color swatches from three different views: RGB, CMYK and HSB. Dragging a swatch of one color space converts those values to each color space upon drop. Plus, I can drag swatches out to apps that accept NSStringPboardType. The problem I'm having is with the NSColorPboardType.
In my own app, I put the NSColor being dragged into an NSData object. So, basically I get something like the following (pb is the NSPasteboard passed into my function)...
NSColor *dragColor = [self color];
[pb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, NSColorPboardType,
nil] owner:
self];
NSData *data = [NSArchiver archivedDataWithRootObject:dragColor];
[pb setData:data forType:NSColorPboardType];
Then upon drop, I use an instance of NSUnarchiver to get the NSColor back out of the NSData object. This all works just fine internally to my own program, but it doesn't seem to be how the Apple Color Picker does things. I cannot drag colors from the color picker into my own app. To me, this means I'm expecting color information to arrive in a different format than the color picker supplies. Ultimately this begs the real question of, "How do I figure out the ways in which applications are delivering/accepting such color information?" and then to take that further, how do I figure out how any given application is expecting ANY kind of data? Lots of things have to be bundled up nice and neat into NSData objects, so this strikes me as a fundamental concept I need to understand.
Any assistance will of course be HUGELY appreciated.
------------------------------------------------------------------
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