I’ve tried every example I could find on this site before I posted this, I’m sure its something stupid.
I’m just trying to retrieve the currently selected title of an nspopupbutton using applescript and put it a variable.
Everything I’ve tried doesn’t do anything.
Can somebody steer me in the right direction
I’ve figured out all the other controls on my form but this one has stumped me.
I have even downloaded some example code and it didn’t work either.
i tried using:
set itemselection to NSpopupbutton’s titleofselecteditem()
You’re doing 2 things wrong here. First, you are addressing the message (the method titleOfSelectedItem) to the NSPopupButton class instead of an instance of the popup button, and second, you didn’t capitalize the method name properly. You need to define a property for your button and set it to missing value. Then connect that in IB to your button. If you call your button myPopup, you would do this:
property myPopup:missing value
then somewhere in your code:
set itemSelection to myPopup’s titleOfSelectedItem()
OK I thought this might be a problem but everytime i type titleOfSelectedItem() xcode automatically changes it to titleofselecteditem(). Do you know why that is? I cant seem to make those capital letters stay.
Ric thanks alot for your time and help. This one is driving me nuts.
Yes, this is a problem in ASOC – if you type something wrong, it seems to remember it and won’t let you correct it. There are two solutions. You can spell it correctly with pipes around it and then compile : |titleOfSelectedItem|()
or,
you can delete the offending letters, so: titlefelectedtem (I’ve deleted the lower case o,s and i), then close your program and xcode (you must close xcode not just your program), then reopen, type in the correct letters and compile.