subclassing NSColorWell
subclassing NSColorWell
- Subject: subclassing NSColorWell
- From: Jason Alexander <email@hidden>
- Date: Sat, 26 Apr 2003 13:11:40 +0100
I'm trying to subclass NSColorWell so that, if the user drags from it
to a NSTextView, what happens is that an appropriate string gets
inserted into the text view, instead of changing the color of the text.
I've tried overriding mouseDragged and mouseDown in my subclass as
follows, but it didn't work. (the textRepresentationForColor method
returns the string I want inserted). Any suggestions would be
appreciated.
-(void)mouseDragged:(NSEvent*)event
{
[super mouseDown: event];
NSPasteboard *pb = [NSPasteboard pasteboardWithName: NSDragPboard];
[pb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil]
owner:nil];
[pb setString: [self textRepresentationForColor] forType:
NSStringPboardType];
}
- (void) mouseDown: (NSEvent *)event
{
[super mouseDown: event];
NSPasteboard *pb = [NSPasteboard pasteboardWithName: NSDragPboard];
[pb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil]
owner:nil];
[pb setString: [self textRepresentationForColor] forType:
NSStringPboardType];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.