Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 2, 2012, 11:25 AM   #1
sjmonty99
macrumors newbie
 
Join Date: Aug 2012
Location: SoCal
How to show/hide objects in Cocoa Applescript application

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
etc.

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.
sjmonty99 is offline   0 Reply With Quote
Old Aug 2, 2012, 08:14 PM   #2
Red Menace
macrumors regular
 
Join Date: May 2011
Location: 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.
__________________
MacBook Pro / OS X Mavericks (10.9.2) / Xcode 5.1 / [and various (much) older stuff keeping dust off the shelves]
Red Menace is online now   0 Reply With Quote
Old Aug 3, 2012, 01:12 PM   #3
Mark FX
macrumors member
 
Join Date: Nov 2011
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.

Code:
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
Mark FX is offline   0 Reply With Quote
Old Aug 6, 2012, 11:02 AM   #4
sjmonty99
Thread Starter
macrumors newbie
 
Join Date: Aug 2012
Location: SoCal
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.
sjmonty99 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:21 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC