Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 2, 2012, 12:25 PM   #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, 09:14 PM   #2
Red Menace
macrumors 6502
 
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 Yosemite (10.10) / Xcode 6.1 / RubyMotion FTW
Red Menace is offline   0 Reply With Quote
Old Aug 3, 2012, 02: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, 12:02 PM   #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

Similar Threads
thread Thread Starter Forum Replies Last Post
Hide OSX System Preferences in Applescript for toggling ignore trackpad in Mavericks? mactp Mac Programming 9 Mar 16, 2014 07:03 PM
XCode - Cocoa-applescript question djjasonsa Mac Programming 3 Feb 21, 2013 04:50 PM
Saving a cocoa application to like an executable. RookieAppler Mac Programming 16 Feb 11, 2013 12:02 PM
General: The apps show up after hide them Processor iOS 6 2 Oct 11, 2012 05:58 AM
COMBOBOX populate from text file (cocoa applescript) nicoboss Mac Programming 4 Jun 29, 2012 02:36 PM

Forum Jump

All times are GMT -5. The time now is 06:01 PM.

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

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