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

AppleScriptObjC | setHidden function

Hello,


In my script I want to show a hidden progress bar when a button is clicked. I used the function


theProgress's setHidden_(false)


But when I press the button it gives an error "Unrecognized function setHidden_".

Is there a way to fix it?

Posted on Jul 17, 2014 4:00 AM

Reply
10 replies

Jul 17, 2014 5:52 AM in response to Matteo_999

As written that should compile and work. Without seeing the rest of your code no way to say why you are getting the error


This works in code I have with progressIndicator as the outlet for the progress bar in the UI.

on hideBut_(sender)

progressIndicator's setHidden_(true)

end


Are you able to access the progress bar for other functions? Updating it for example.

Jul 17, 2014 8:21 AM in response to Frank Caggiano

I tried to do that in another script, and it is:


script AppDelegate


propertyparent : class"NSObject"

property progressBar : missing value



-- IBOutlets

property window : missing value


on applicationWillFinishLaunching_(aNotification)


-- Insert code here to initialize your application before any files are opened

end applicationWillFinishLaunching_


on applicationShouldTerminate_(sender)


-- Insert code here to do any housekeeping before your application quits

return current application's NSTerminateNow

end applicationShouldTerminate_

on buttonClicked_(sender)

progressBar's setHidden_(true)

end buttonClicked_


endscript


It still gives the error:

2014-07-17 17:17:05.674 Prova[458:303] *** -[AppDelegate buttonClocked:]: Unrecognized function setHidden_. (error -10000)


Now I'm wondering if should I import any class, such as NSView...

Jul 17, 2014 8:58 AM in response to Matteo_999

Could you post a screen shot of the Connections Inspector for this. Not that I don;t beleive you but perhaps I'll see somehting that you are missing.


Just noticed in the error message


2014-07-1717:17:05.674 Prova[458:303] *** -[AppDelegate buttonClocked:]

it is referring to buttonClocked:, the method where you have setHidden_ is buttonClicked. What is buttonClocked:


BTW what version of Xcode are you runing?


One last thing whrre are you getting that error message from?

Jul 17, 2014 9:06 AM in response to Matteo_999

Ok well this workd for me. It has to be in your connections


--

-- TMAppDelegate.applescript

-- testMAt

--

-- Created by Frank Caggiano on 7/17/14.

-- Copyright (c) 2014 Frank Caggiano. All rights reserved.

--


script TMAppDelegate


propertyparent : class"NSObject"



-- IBOutlets

property window : missing value

property progressBar : missing value



on applicationWillFinishLaunching_(aNotification)


-- Insert code here to initialize your application before any files are opened

end applicationWillFinishLaunching_


on applicationShouldTerminate_(sender)


-- Insert code here to do any housekeeping before your application quits

return current application's NSTerminateNow

end applicationShouldTerminate_


on buttonClicked_(sender)

progressBar's setHidden_(false)

end buttonClicked_



endscript



User uploaded file

Jul 17, 2014 6:53 PM in response to Matteo_999

Glad you got it working.

don't I have to set the bindings such as "Value" or "Hidden"?

No all you need to do is connect the UI element to the property (for output to) or method (for input from) in your code.


When you drag a UI element out and place it in the window for your app you are creating an instance of the UI Class. That is if you drag out a ProgressIndicator you create an instance of it that you can then send messages to or receive messages from.


So if oyu want to make the ProgressIndicator visible or invisible you send it the message setHidden: with the correct value (true or false). If you want to set the ProgressIndicatior you send it the message incrementBy:


So if I have a property in my code

property progressIndicator : missing value


and I connect it to the ProgressIndicator UI element I can then do things like

progressIndicator's setIndeterminate_(false)

progressIndicator's setDoubleValue_(0)

progressIndicator's setMaxValue_(60)

To see the messages a class implements you need to look at the classes documentation. Xcode is great for this as you can select an element in the Interface Builder and then select the Quick Help Inspector to get help and links for that particular element.


So if you select the ProgressIndicator you will see


User uploaded file

along with links to the full class description as well as links to programming guides and sample code.


Now there is a way to bind individual parts of the code, such as value and hidden. These are show in the Bindings Inspector but these are for an somewhat advanced usage, that is you can do all you need to do for now with just connection between the property and the element. What bindings enable you to do is to have a more direct and automated way for one element to affect another or for it to affect a piece of code.


Let's say you have a slider that you use to input a number into your code. Also say you have a text view you use to both display the value of the slider and to also allow users to directly input a number. So when the slider moves you want the text view to update and if a user enters a number in the text view you want to set the slider to that value.


Without bindings you can do this by having the slider call your code, you retrieving the value and then you display that value in the text view. Conversely if a user enters a number in the text view you can retrieve that and then set the value of the slider. This works fine and is sufficient for many programs.


However with bindings it is possible for the slider to directly set the value in the text view and to have the number entered in the text view directly set the slider. One thing to keep in mind for bindings to work you need to be familiar with Key-Value Coding Programming Guide: Introduction. I


This might have been more information then you were looking for or need, if so you can safely ignore it. As I said you can do what you need to do here without bindings.


regards

AppleScriptObjC | setHidden function

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