Re: Drag and drop color swatches
Re: Drag and drop color swatches
- Subject: Re: Drag and drop color swatches
- From: glenn andreas <email@hidden>
- Date: Wed, 8 Dec 2004 09:32:48 -0600
On Dec 8, 2004, at 12:01 AM, Christopher Drum wrote:
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.
Why not just use
[NSColorPanel dragColor: color withEvent: theEvent fromView: controlView] which will handle everything for you?
Glenn Andreas email@hidden
<http://www.gandreas.com/> oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
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