button text color, changing with a script

I know this seem simple but I’ve searched everywhere and not been able to figure it out on my own.

I’d like to indicate that something is toggled on or off by changing the color of the text on a button.

This is what I’ve tried so far (these don’t work)


if tshuffle is true then
			tell window "music"
				tell button "shuffle"
					set text color to "blue"
				end tell
			end tell
		end if

--or this?

		if trepeatall is "all" then tell button "repeatall" to set text color to "blue"
		if trepeatall is "one" then tell button "repeatthis" to set text color to "blue"

perhaps i need to refer to something within the button like a “field”?

http://developer.apple.com/documentation/AppleScript/Reference/StudioReference/sr5_control_suite/chapter_5_section_5.html#//apple_ref/doc/uid/20011219-ASKControlViewSuite.Classes.NSButton

“Color” isn’t an accessible property of buttons, so it isn’t changeable by AppleScript itself. It also doesn’t seem to be a binding available in Cocoa’s NSButton class, either, so I’m not sure how you’d go about doing it.

If this is a “loop”/“repeat all” button like you would see in the iTunes window, consider using two images on the button: one for “off” and one for “on”. Make it a push button and you’re good to go.

Crud…I was kind of worried about this.

You are correct, I am building a specialized iTunes interface…I’m trying to be very conservative with resources and such. So i am only using images where necessary. I guess this is just one of those where i’ll have to give in and use images.

Thanks.

To be honest, it’s probably better as an image, anyway. Exercise your creative side!

There’s nothing wrong with a little button with an image on it. There’s a reason Apple uses them in iTunes/iChat/Remote Desktop/etc. :slight_smile:

G’luck. :slight_smile: