Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Buttons with AppleScript

Hello, I am very new with Xcode. I have 2 questions about how to do things via an Cocoa-AppleScript Mac App. First, how can I have the AppleScript do something when a button is pressed on the main window of the app? Also, how can I make the progress bar move when the AppleScript is completing a task? Thank Tou so much for your help.

Mac mini, OS X Mountain Lion (10.8.3)

Posted on Sep 9, 2013 10:35 PM

Reply
1 reply

Sep 10, 2013 4:39 PM in response to AppleMan001

To do something when a button is pressed you will need to create action handler(s) that get called when the button is pressed, for example:


ondoButtonStuff_(sender) -- do stuff when a button is pressed


logsender's title() -- the name of the button


# whatever

enddoButtonStuff_


The action handler receives one parameter (the button), and is connected to the desired button(s) in the Interface Editor.


To make a progress indicator move, you will need to break up your task and increment the progress bar each time through the loop - see the NSProgressINdicator Class Reference for available methods. Note that if you are using something like a repeat loop, you will need to add code to handle events so that your user interface gets updated.


I have an example project that uses timers and a progress bar if you want to look at that - it can be downloaded here.

Buttons with AppleScript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.