Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacRumoron

macrumors 6502
Original poster
Sep 6, 2005
324
0
SOLUTION FOUND, read edit 3

I have an nsview, and I want to be able to drag this nsview into a colorwell and make the colorwell change its color. How can I do this?

Or another question would be: how is data stored in NSColorWell for the NSColorPboardType? Because it isn't just an archived NSColor.

Hope this makes any sense :eek:

EDIT: This is a code snippet from mouseDragged in my NSView.
Code:
pb = [NSPasteboard pasteboardWithName:NSDragPboard];
[pb declareTypes:[NSArray arrayWithObjects:NSColorPboardType, NSStringPboardType, nil] owner:self];
		
[pb setString:@"test" forType:NSStringPboardType];
[pb setData:[NSArchiver archivedDataWithRootObject:[NSColor whiteColor]] forType:NSColorPboardType];
		
NSLog(@"%@", [NSColor colorFromPasteboard:pb]);

Then when I drag I get this message

Code:
-[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4, 0xb, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d)

What am I doing wrong?

Thanks.

EDIT2: ok i found out it is supposed to be NSKeyedArchiver not NSArchiver, but NSColorWell's still don't do anything when I drag to it

EDIT3: the problem was that I had this in my NSView
Code:
- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)isLocal
{
	return NSDragOperationCopy;
}

once i commented that out everything worked perfectly :)
 
I have an nsview, and I want to be able to drag this nsview into a colorwell and make the colorwell change its color. How can I do this?
You want to drag an NSView into a color well? That's an odd way of doing things, I think the way they're meant to be used is to select an object you want to affect first, then the well changes the color of that object (or objects). Not saying there's not a way to do that, just that I don't think they're intended to be used that way.
 
Sorry, I meant that I have this NSView, and when I drag it, a colored square box appears (just like when you drag from NSColorWell). I want to be able to make it so when you drop that square box in an NSColorWell, it will change the colorwell into a certain color.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.