我在'net:
周围的各个地方找到了这段代码tell window 1
tell menu of popup button 1
delete every menu item
repeat with catListItem in catList
make new menu item at end of menu items with properties {title:catListItem}
end repeat
end tell
end tell
当我在Cocoa-AppleScript应用程序的AppDelegate脚本中使用它时,Xcode给出了一个错误:* t2t_AppDelegate.applescript:25:错误:预期的行尾但找到了标识符。 (-2741)*(第25行是“告诉菜单......”)
我不确定我错过了什么,这将允许我使用我从另一个应用程序绘制的术语列表(catList)动态填充弹出按钮。有什么建议吗?
答案 0 :(得分:0)
除非您运行的东西早于Snow Leopard,否则您看起来正在使用AppleScript Studio术语(在Snow Leopard中已弃用)。使用当前的 AppleScriptObjC 框架,用户界面项通过插座属性引用,例如:
property myPopUp : missing value
在界面编辑器中,此属性连接到弹出按钮,允许您在NSPopupButton类及其父级中使用各种方法,例如 addItemsWithTitles 。一旦定义并连接了所有内容,您将使用类似的内容:
set catList to {"next item", "another item", "Items added"}
myPopUp's addItemsWithTitles_(catList)