I have an NSpopupbutton that is populated from the appdelegate to the MainMenu.xib like:
property theSelection: "Blue Set"
on applicationWillFinishLaunching_(aNotification)
thePopup's removeAllItems()
set setList to {"Orange Set", "Green Set", "Blue Set", "Yellow Set", "Black Set"}
thePopUp's addItemsWithTitles_(setList)
end applicationWillFinishLaunching_
where theSelection is the value of the item selected that gets passed back to the appdelegate
I can set theSelection to “Blue Set” as above, and it works as expected; that is if the popup button is not touched by the user, the script handler (a ‘Go’ NS button is clicked) doesn’t pass anything back to appdelegate, and the pre-existing variable declaration is used.
But, is there any way to get the NSPopupbutton to show a pre-selected value that may be in the middle of the list? As it stands, even though I can pre-define the variable in the appdelegate, the first item (Orange Set) of the NSPopupbutton is always displayed when run. I can’t hard-code it in the .xib because the button’s items don’t exist until they are run in applicationWillFinishLaunching_