Thanks again for the help –
What’s the best way to insert a 60×60 pixel square representation of a color displayed in a colorWell into a textView? I know how to reference the values of the displayed color.
Again. thanks.
-paul.
This action works using the colorWell as the sender. It doesn’t work when I add it to a button initialized action:
NSColor *wellColor;
wellColor = [colorWell color];
float
red, green, blue;
red = [wellColor redComponent];
green = [wellColor greenComponent];
blue = [wellColor blueComponent];
[colorWell setColor:wellColor];
[colorWell setColor:[NSColor colorWithCalibratedRed:red green:green blue:blue alpha:1.0]];
wellColor = [colorWell color];
NSRect r = NSMakeRect(190, 130, 100, 100);
NSBezierPath *bp = [NSBezierPath bezierPathWithRect:r];
NSColor *color = wellColor;
[color set];
[bp fill];
The simplest way is to use NSTextAttachment and attach it as an image (drawing a solid-color-filled image is a simple task you can learn about with the basic drawing documentation). Otherwise, you’ll have to get into subclassing and customizing parts of the text system to make room for and draw the color there yourself.