How to make a button work only one time per application launch?

Hello scripters,

I have a button that if accidently double clicked it executes it’s code twice… anyway to stop this from happening?

Thanks
Dave

Do you want the button to be unusable until some operation is complete, or do you want the button to be disabled permanently after the operation is done the first time?

Disable the button after the first time.

Thanks
Dave

set enabled of yourButton to false

Thank you!

I can’t seem to get this to work. Here is the code for this portion of the script.

on clicked theObject
	
	load nib "Thankyou"
	
end clicked


on awake from nib theObject
	
	set enabled of "grantaccess" to false
	
end awake from nib

This is the script for the button. Does this seem correct? Actually now that I think about it I guess the “set enabled of” should be in the nib that is opened by the button, correct? I tried this and still was unsuccessful.

Thanks
Dave

Try this:


on clicked theObject
load nib "Thankyou"
set enabled of button "grantaccess" of window "main" to false
end clicked

Substitute “main” with the name of the window the button is on. That way, you only need one script, and it works. :slight_smile:

Awesome, worked great!!

Thanks and Cheers!!

Dave