可可AppleScript的NSOpenPanel? [英] Cocoa-Applescript NSOpenPanel?

查看:437
本文介绍了可可AppleScript的NSOpenPanel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在可可的AppleScript做一个 NSOpenPanel ?有没有什么好的教程?我熟悉AppleScript的,但没有真正的可可一部分。我需要一个笔尖的NSOpenPanel?我想提出一个Automator的行动。 看到我的previous问题

How do I do an NSOpenPanel in Cocoa-Applescript? Are there any good tutorials? I am familiar with Applescript, but not really the Cocoa part. Do I need a nib for the NSOpenPanel? I am making an Automator action. See my previous question.

推荐答案

巴蒂尔士丹利的PDF图书 AppleScriptObjC探索< /一>是一个获得AppleScriptObjC教程 - pretty多所有的来自苹果的例子是现有ObjC文档中,将需要被转换

Shane Stanley's PDF book AppleScriptObjC Explored is the one to get for AppleScriptObjC tutorials - pretty much all of the examples from Apple are in the existing ObjC documentation and would need to be converted.

有一个Automator的路径弹出按钮,您可以在您操作的界面中使用,但一个基本打开面板这样的东西下面的(它不需要自己的笔尖):

There is an Automator path pop-up button you can use in your action's interface, but a basic open panel goes something like the following (it doesn't need its own nib):

set defaultDirectory to POSIX path of (path to desktop) -- a place to start

tell current application's NSOpenPanel's openPanel()
    setFloatingPanel_(true)
    setTitle_("Panel Test")
    setPrompt_("Choose") -- the button name
    setMessage_("Choose some stuff:")
    setDirectoryURL_(current application's NSURL's URLWithString_(defaultDirectory))

    setCanChooseFiles_(true)
    setCanChooseDirectories_(true)
    setShowsHiddenFiles_(false)
    setTreatsFilePackagesAsDirectories_(false)
    setAllowsMultipleSelection_(true)

    set theResult to it's runModal() as integer -- show the panel
    if theResult is current application's NSFileHandlingPanelCancelButton then quit -- cancel button
    set theFiles to URLs() as list --> a list of NSURLs
end tell

请注意,如果使用的AppleScript编辑器,你不能直接从编辑器中运行AppleScriptObjC code,你需要在可可的AppleScript小程序运行。有一个 ASObjC转轮的后台应用程序(也由Stanley先生),可以是从编辑器中使用,虽然。

Note that if using the AppleScript Editor, you can't run AppleScriptObjC code directly from the editor, you need to run it in a Cocoa-AppleScript applet. There is an ASObjC Runner background application (also by Mr. Stanley) that can be used from the editor, though.

这篇关于可可AppleScript的NSOpenPanel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆