Re: subclassing NSColorWell
Re: subclassing NSColorWell
- Subject: Re: subclassing NSColorWell
- From: Esteban Uribe <email@hidden>
- Date: Sun, 27 Apr 2003 14:33:17 -0700
Hi,
On Saturday, April 26, 2003, at 05:11 AM, Jason Alexander wrote:
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.
You may want to subclass some of the NSColorWell's NSDraggingSource
protocol methods (instead of mouseDragged and mouseDown) as these deal
directly with the act of dragging and dropping.
Similarly, you may have to modify this protocol's methods in
NSTextView, thought just making sure you pass an NSString to the
dragging NSPasteboard should be enough... it think.
See
<
http://developer.apple.com/techpubs/macosx/Cocoa/Reference/
ApplicationKit/ObjC_classic/Protocols/NSDraggingSource.html> for more
info.
-Esteban
-(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.
_______________________________________________
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.