Enable/Disable a button in Cocoa interface

ahoy scripters,

i’m making a little application launcher for some public machines, and would like to do the following: one application - iDVD - is not installed on all of the machines, so on machines which it isn’t installed on, i’d like to disable the button - i.e. “grey it out.”

i can properly detect whether or not it’s there, and have a corresponding boolean to go with it.

is there a way to disable a button, based on a boolean value calculated in the applescript…? i can make it so the button does nothing, but it’s still click-able at this point…

Is this what you mean?

Jon

nnnnot quite, but thanks again for the code for detecting the burner… you’ll get credit in thee about box, unless you don’t want it :smiley:

i’m using interface builder to stick the info from the script together… so, for example, the results of the burner detection go into a text field defined in there. as for the buttons, i’ve got it set up like this:


on clicked theObject
	if the name of theObject is equal to "start-iMovie" then
		launch application "iMovie"
	else if the name of theObject is equal to "start-fcp" then
		launch application "Final Cut Pro"
	else if the name of theObject is equal to "webpage" then
		open location "http://everton.mit.edu/"
	else if the name of theObject is equal to "start-idvd" then
		set the_optical_type to do shell script "ioreg -c IODVDServices | grep 'Device Characteristics' | cut -d '"' -f 18 | cut -c1-7"
		if the_optical_type = "DVD-RW " then
			set burner to true
		else
			set burner to false
		end if
		if (burner = true) then
			launch application "iDVD"
		end if
	end if
end clicked

so, as you can see, i’ve ghetto-rigged your command line detector to set a boolean, such that if it’s true, the button associated with “start-idvd” will launch iDVD when pressed… otherwise, it does nothing. instead of doing nothing, i’d like the button to be disabled, but still present.

it might be impossible to do with straight applescript, as it requires fiddling with the nib.

Sorry, I didn’t understand. You should post this topic in the AppleScript Studio forum.

Jon

set enabled of button "button_" of window "main" to false