Mac How to show/hide objects in Cocoa Applescript application


macrumors newbie
Original poster
Aug 2, 2012
I need to show/hide things like progress indicators & text fields at various times during the life of the app I'm making. I cannot find anywhere that shows how to do this. It appears as though this existed in the Applescript Studio days with commands like:
set visible of myProgressBar to true
set visible of myProgressBar to false

What is the compatible command for our current versions of XCode?

I'm also looking for a way to switch a Progress Indicator between Intermediate (checked in IB) and Non-Intermediate (not checked in IB) states when the app is running. Is this possible? I need the "barber pole" style view at times and an incremental/numerical progress at other times.

Red Menace

macrumors 6502
May 29, 2011
Littleton, Colorado, USA
You will have to get used to using the Cocoa documentation, since AppleScriptObjC doesn't hide the various classes and methods like AppleScript Studio did.

Don't forget that methods of the parent class(es) can also be used. For progress indicators and text fields, take a look at NSView's setHidden: method.

The NSProgressIndicator class has a setIndeterminate: method that is used to switch to the barber pole.

Mark FX

macrumors regular
Nov 18, 2011
West Sussex, UK
As Red Menace has said, most of the UI elements and controls inherit from the NSView class, so you can use the setHidden method to hide or show these controls, also you can use the NSView's isHidden method to find out there current visible status, like this.

property label : missing value    --Link to this label in Interface builder
property button : missing value    --Link to this button in Interface Builder

on buttonPressed_(sender)    --Link the button to this method in IB
    if label's isHidden() = 0
        label's setHidden_(1)
    else if label's isHidden() = 1 then
        label's setHidden_(0)
    end if
end buttonPressed_
You'll notice that ApplescriptObjC uses 1 as a boolean value of YES, and 0 as a value of NO.

Hope this Helps.

Regards mark


macrumors newbie
Original poster
Aug 2, 2012
I've got them both working now. Thank you so much. Found the documentation and can hopefully apply the methods learned here towards the rest of the code in my project.