• 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
Re: subclassing NSColorWell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >subclassing NSColorWell (From: Jason Alexander <email@hidden>)

  • Prev by Date: Re: converting text input in any encoding to unicode
  • Next by Date: Re: converting text input in any encoding to unicode
  • Previous by thread: subclassing NSColorWell
  • Next by thread: Getting info of a background-only app
  • Index(es):
    • Date
    • Thread