Article:
 |
|
Creating a Color Meter Using Cocoa
|
| Subject: |
|
Color wheel... |
| Date: |
|
2001-06-20 06:31:33 |
| From: |
|
rainwadj
|
|
|
|
As mentioned in the article, clicking on the color well brings up a color wheel (et al). Clicking around in the color wheel updates the color well, but not the sliders or the text fields. How would I do this? |
Showing messages 1 through 9 of 9.
-
Color wheel...
2001-06-20 07:46:12
rainwadj
[View]
-
Color wheel...
2001-06-20 08:26:02
davidmasters
[View]
-
Color wheel...
2001-06-20 10:40:23
rainwadj
[View]
-
Color wheel...
2001-06-20 11:39:04
johnts
[View]
-
Color wheel...
2001-06-20 12:50:22
davidmasters
[View]
-
Color wheel...
2001-06-22 09:17:54
donarb
[View]
-
Color wheel...
2001-06-20 19:54:29
johnts
[View]
-
Color wheel...
2001-06-20 19:39:24
johnts
[View]
-
Color wheel...
2001-06-20 19:28:20
johnts
[View]
- (IBAction)updateControls:(id)sender
{
NSColor *theColor = [sender color];
redValue = [theColor redComponent];
[redField setFloatValue:redValue];
[redSlider setFloatValue:redValue];
greenValue = [theColor greenComponent];
[greenField setFloatValue:greenValue];
[greenSlider setFloatValue:greenValue];
blueValue = [theColor blueComponent];
[blueField setFloatValue:blueValue];
[blueSlider setFloatValue:blueValue];
alphaValue = [theColor alphaComponent];
[alphaField setFloatValue:alphaValue];
[alphaSlider setFloatValue:alphaValue];
}
Looking at the class defs for NSColor helped a lot. It seems like it would have been cleaner to use getRed:green:blue:alpha, since I wanted them all anyway, but compiling with [theColor getRed:redValue...] complained that redValue... was an incompatible type. The method wants float * for the parameters, and the someValue variables are floats. (I feel like I'm forgetting something very basic here...)