除了其自己的文件类型弹出按钮之外,还向 NSDocument 的保存面板添加附件视图

发布于 2024-11-06 04:22:04 字数 428 浏览 4 评论 0原文

我有一个基于 NSDocument 的应用程序,可以保存为多种文件类型,因此在保存文档时,NSDocument 会在保存面板中添加一个弹出按钮作为其附件视图,让用户选择类型他们想另存为。好的。

现在,我想将另一个视图包含在保存面板中,但如果我只是覆盖 -[NSDocumentprepareSavePanel:] 并使用 -setAccessoryView:要插入我自己的视图,它会替换文件类型弹出按钮,因此只有我的视图出现在保存面板中,而不是弹出按钮。

NSDocument 有什么方法可以让我自己的视图其文件类型弹出窗口同时出现在保存面板中吗?看起来我可以抓住现有的附件视图,将其与我自己的附件一起修补到容器视图中,然后将其放回原处,但这似乎很黑客,并且想知道是否有更好的方法可以做到这一点,我已经错过了。

I have an NSDocument based application that can save to multiple file types, so when saving a document, NSDocument helpfully adds a pop-up button to the save panel as its accessory view that lets the user choose what type they'd like to save as. Nice.

Now, I've got another view that I'd like to include in the save panel, but if I just override -[NSDocument prepareSavePanel:] and use -setAccessoryView: to insert my own view, it replaces the file type pop-up button, so only my view appears in the save panel and not the pop-up button.

Is there any way that NSDocument provides to have both my own view and its file type pop-up appear in the save panel at the same time? It looks like I could grab the existing accessory view, patch it together with my own accessory into a container view, and put that back in, but that seems pretty hackish, and was wondering if there's any better way to do this that I've missed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽手叙旧 2024-11-13 04:22:04

不,没有明显更好的方法。可能会更容易/更好:

  1. 在您自己的附件视图笔尖中创建文件类型弹出窗口
  2. 在运行时,找到 NSSavePanel 的现有附件弹出窗口,
  3. 调用 setTarget:< /code> / setAction: / setMenu: 在弹出窗口上,参数是从现有弹出窗口的设置方式中提取的。

这就是我们的应用程序执行操作的方式,并且可以更轻松地将文件类型弹出窗口与其余控件一起明显地定位,因为它们都在同一个笔尖中。

No, no significantly better way. It may be slightly easier/nicer to:

  1. Create a file type pop-up in your own accessory view nib
  2. At run-time, find the NSSavePanel's existing accessory popup,
  3. Call setTarget: / setAction: / setMenu: on your popup with arguments pulled from how the existing popup is set.

That's the way our app does things, and it makes it easier to visibly position the file type popup with the rest of your controls, since it's all in the same nib.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文