处理 OSX Dock 拖放
我四处寻找有关如何在 OSX 中处理拖放至 Dock 的信息。 拖放文档 (http ://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html#//apple_ref/doc/uid/10000069)我发现所有处理都是从一个视图拖动到另一个视图。 如果有人能给我一些代码示例,那就太好了。
我正在使用 PyObjC 新娘编写我的应用程序,但 Cocoa 示例同样受欢迎:-)
I looked high and low for information on how to handle drag n drop to the dock in OSX. The drag n drop documentation (http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html#//apple_ref/doc/uid/10000069) I found all deal with dragging from view to view. If anyone can point me to some code samples, that would be excellent.
I'm writing my app using the PyObjC bride, but Cocoa examples would be equally welcome :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
嗯,看来我问得太早了。 这是一个很棒的教程,展示了如何做到这一点:
http://recurser.com/articles/2007/04/13/cocoa-drag-to-dock-to-open/
基本上,只需将控制器设置为 NSApplication 的委托并实现 openFile方法。
Well, looks like I asked too soon. Here is a great tutorial that shows how one does it:
http://recurser.com/articles/2007/04/13/cocoa-drag-to-dock-to-open/
Basically, just set your controller to be the delegate of NSApplication and implement the openFile method.
这是几周前的一个类似问题。我的回答涉及拖动文件,这就是您所说的; 另一个答案涵盖拖动数据,例如图像和文本位(不是图像文件或文本文件,而是裸数据)。
Here's a similar question from a couple weeks ago. My answer covered dragging files, which is what you're talking about; the other answer covers dragging data, such as images and bits of text (not image files or text files, but bare data).
http:// /lethain.com/entry/2008/aug/06/cocoa-drag-and-drop-text-into-the-dock-icon/ 涵盖了使用 pyobjc 将文本拖放到停靠栏图标中。 您可以轻松地将其改编到其他文件中。
http://lethain.com/entry/2008/aug/06/cocoa-drag-and-drop-text-into-the-dock-icon/ covers dragging and dropping text into a dock icon with pyobjc. You can adapt this into other files reasonably easily.
这是 Xcode 4 的较新文章
http://fredandrandall.com/blog/2011/09/12/how-to-open-any-file-you-drag-onto-your-apps-dock-icon
Here is a newer article for Xcode 4
http://fredandrandall.com/blog/2011/09/12/how-to-open-any-file-you-drag-onto-your-apps-dock-icon
这是一个示例项目“DockDrop”。
Here is an example project "DockDrop".