Font Color of Checkbox (Switch)

Is there a way in the IDE or programmatically to set the font color for a checkbox/switch?

I tried in the font dialog box of the IDE but it didn’t change the font to the color selected.

I then tried to do it in code but keep getting error messsages. Here’s my code

on awake from nib theObject
	if name of theObject = "cbFileInfo" then
		tell button "cbFileInfo" of window "addWin"
			set text color to {65535, 65535, 65535}
		end tell
	end if
end awake from nib

you could do it with a little Objective-C ‘magic’:

add these files to your project:

//  MYButtonAdditions.h

#import <Cocoa/Cocoa.h>

@interface NSButton (MYButtonAdditions) 
-(void)setTitleRedValue:(int)red greenValue:(int)green blueValue:(int)blue;


//  MYButtonAdditions.m

#import "MYButtonAdditions.h"

@implementation NSButton (MYButtonAdditions) 

-(void)setTitleRedValue:(int)red greenValue:(int)green blueValue:(int)blue{

	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSAttributedString *oldTitle = [[[NSAttributedString alloc] init] autorelease];
	oldTitle = [self attributedTitle];
	NSMutableDictionary *theAttribs = [[[NSMutableDictionary alloc] initWithDictionary:[oldTitle attributesAtIndex:0 effectiveRange:nil]] autorelease];

	[theAttribs setObject:[NSColor colorWithCalibratedRed:(float)red/65635.0
	NSAttributedString *newTitle = [[[NSAttributedString alloc] 
										initWithString:[oldTitle string] 
											attributes:theAttribs] autorelease];
	[self setAttributedTitle];
	[pool release];

then you can set the color from AppleScript with a ‘call method…’:

	tell button "button" of window "main"
		call method "setTitleRedValue:greenValue:blueValue:" of it with parameters {65635, 22000, 0}
	end tell