Newbie question about buttons

Hi

I have just created my first Applescript Studio app - a progress bar. I have only been scripting for a week so please bear with me.

My question concerns how to control buttons and other objects inside the GUI of the main window of the app.

I know I can update text fields with a statement along the lines of:

tell window 1 of application "My Progress Bar" to tell text field "Bottom Message" to set content to "Hello"

I know I can enable or disable a button with a statement along the lines of:

tell window 1 of application "My Progress Bar" to set enabled of button "Cancel Button" to true

But I would like to change the content of the button so that, for example, the “Cancel” button toggles to “Continue” and vice versa when clicked. I have tried the following:

tell window 1 of application "My Progress Bar" to set content of button "Cancel Button" to "Continue"

This seems to execute without an error but the button does not change in appearance.

Another way I thought of doing this was to have two buttons superimposed and hide and unhide as necessary using something like the following:

tell window 1 of application "My Progress Bar" to set hidden of button "Cancel Button" to true

This was coded along the same lines as the “enable” script above which works. However, the “hidden” script just throws an error saying it cannot transform “hidden” into a reference type.

Any suggestions gratefully received. General pointers to information on how to address objects (buttons, bars, sliders) and the limitations of each type of object, would also be most welcome.

Model: iBook
AppleScript: Latest
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

I think I may just have answered my query.

By getting the properties of the relevant button, all seems to be revealed:

tell application "My Progress Bar"
	properties of button "Cancel Button" of window 1
end tell

Then the code to change the button’s appearance is:

tell window 1 of application "My Progress Bar" to set title of button "Cancel Button" to "Hello"

Seems like getting properties of things you want to fiddle with is going to open up all sorts of possibilities!!

I’ll no doubt post again when I bump into another hurdle

and one last reflection on the subject.

While getting the properties of an object shows you what the properties currently are, it does not always help to explain what the options are for the various objects.

Is there any command that can be scripted to list the various options for each of the objects?

For a Newbie, this would be helpful

In your Xcode project, you should see a file called “AppleScriptKit.sdef”; This is the dictionary that you’re application will have.

You should also check out the AppleScript Studio Terminology Reference. (A local copy should have been installed with the Developer Tools.)

kiwilegal wrote:

I’ve just recently discovered (i.e. read) that “hidden” only works for window-type objects, not controls. :frowning:

Cheers, WM

You should be able to use “visible”:

set visible of button "Your Button" of window "Your Window" to true

Thanks for the responses

I am slowly making progress