Apple Event: May 7th at 7 am PT

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

xcode ns pop up button

I am currently writing an applescript xcode project.


How do you set up the ns popupbutton?


For example:


on buttonClick_(sender)


set goodBad to (I want to set this variable by a ns popupbutton)


say goodBad


end buttonClick_


Thanks for your help!!!!

MacBook Pro, OS X Mountain Lion (10.8.2)

Posted on Jun 14, 2013 11:39 PM

Reply
Question marked as Best reply

Posted on Jun 15, 2013 2:27 AM

A couple of ways to get the selection would be by using NSPopUpButton's titleOfSelectedItem or indexOfSelectedItem.

3 replies

Jun 15, 2013 6:34 PM in response to skywalkerkenobi

Those links are to parts of the documentation that Apple provides for the Cocoa API. Learning to navigate the documentation (and there is a lot of it) is important, since it describes what all of the classes and methods are. Unfortunately for regular AppleScripters, almost all of the documentation is for Objective-C (Apple's language of choice), but it can be converted to AppleScriptObjC fairly easily - see the release notes.


You don't really provide much information, but to speak a popup button's selection (the UI will be blocked while speaking) it would be something like:

onbuttonClick_(sender)

setgoodBadtosender's titleOfSelectedItem() astext

saygoodBad

endbuttonClick_


NSTextField is the class for a text field, and it inherits several common methods from the NSControl class - one of which is setStringValue, so to clear a text field you would add a statement in your button handler something like:

myTextField's setStringValue_("")

xcode ns pop up button

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