I’m still new with AppleScript studio but not to AppleScript and I’m having a bit of an issue making a program work the way I want to.
Right now I have a program that when you hit the “start” button it goes through a long loop that can take a long time to finish. The problem is since this happens inside “on clicked theObject” no other buttons are responsive after you click the “start” button.
Ideally I’d like to allow the user to hit the “cancel” button and break out of loop that starts when they hit the “start” button, just not sure how to do it since no other keys can even be pressed while the loop is going in “on clicked theObject.”
A second question that is much less important… but still curious about. Is there anyway to rename a key (rename it so the user sees it) after it has been pressed? I’d like the “start” key to become the “stop” key after the user presses it.
If you do a google search of this forum, you should be able to find solutions to your problem. There are several recent posts on stopping action while in a loop. I can’t remember them but try searching for “double repeat loop” which shows how to go about cancelling action. There are a few others.
Basically, you set up a global Boolean property (for example, property userCancelled: false) then if a “Cancel” button is pressed by the user, set the property to true. Test that property inside your loop and have the process stopped if it is true.
For dynamically changing the title of the button, simply issue a statement in the “on clicked” handler to change the title of the button to something else after it is clicked…along with other actions you want.
I hope the above get you up and going. Reading Apple’s documentations on AppleScript Studio programming should also help you if you are just starting on it. You can access these documents in XCode.