如何在Xcode中为自定义Automator Action项目连接按钮的已发送操作

jwe*_*aks 5 xcode cocoa applescript automator applescript-objc

我在Xcode的Interface Builder中,创建了一个Cocoa-Applescript自定义Automator Action.我在界面中有一个Button和一个ComboBox菜单.我想在用户单击Button时填充ComboBox菜单的内容值.我创造了

on buttonSentAction_(sender)
    -- set popupMenuContentValues of my parameters() to aList as list
    my popupMenu's addItemsWithObjectValues_(aList)
end buttonSentAction_
Run Code Online (Sandbox Code Playgroud)

在applescript文件中的处理程序,但当我从按钮拖动到文件的所有者时,文件的所有者不会突出显示我放弃连接.我期待的是它放弃并让我选择buttonSentAction_处理程序来接收发送的动作.如果我右键单击File's Owner,我在Applescript控制器文件中创建的收到的操作处理程序不会显示.(注意,我仍然不确定在该处理程序中填充ComboBox菜单的正确行.) 屏幕抓取将组合框链接到文件所有者

我可以在"FM to Named Text Boxes"中看到示例macosxautomation.com上的Automator Action项目在IB中有一个按钮,您可以在Bindings Inspector中看到按钮的发送动作实际上已连接到文件所有者,并且applescript文件具有匹配的处理程序.另外,我默认将File's Owner的控制器设置为applescript文件.显然,我遗漏了一些关于在Automator Action Project中挂起已发送动作的具体内容.有帮助吗?

jwe*_*aks 1

更新:我让它工作了。\n关键是您必须先为对象创建一个 Outlet,然后才能绑定到发送操作处理程序。

\n\n

我删除了该按钮并使用新的命名方案重新开始。这次,文件的所有者收到了拖动,所有内容都连接到发送的操作,并且按预期工作。我做的事情和以前一模一样,所以为什么第一个操作处理程序无法接收 IB 中的已发送操作是一个谜。

\n\n

示例代码如下:

\n\n
on searchTypeMatrixWasClicked_(sender)\n    -- called with the matrix sent action\n    set theIndex to (actionTypeIndex of my parameters()) as integer\n    if theIndex is 0 then\n    -- do stuff, etc.\n    else if theIndex is 1 \xe2\x80\xa6\n    end if\nend\n
Run Code Online (Sandbox Code Playgroud)\n\n

IB 中的绑定检查器

\n