• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
subclassing NSColorWell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: subclassing NSColorWell
      • From: Esteban Uribe <email@hidden>
  • Prev by Date: Re: Rendezvou
  • Next by Date: Getting info of a background-only app
  • Previous by thread: Getting IPs of all the remote machines
  • Next by thread: Re: subclassing NSColorWell
  • Index(es):
    • Date
    • Thread