希望将选项卡引入基于文档的应用程序,有想法吗?
我有一个基于文档的应用程序,到目前为止,它只是使用每个文档的新窗口来编辑文档。
我现在添加了创建项目的功能,该项目本身就是一个文档。该项目将包含一个文件列表,可以使用(希望)与我现有的 NSDocument 子类相同的代码进行编辑,但文档编辑器将嵌入到项目窗口中,而不是在一个新窗口。
例如,Xcode 如何在编辑器窗格中打开每个文件,而不为每个文档使用一个新窗口?我认为它使用基于文档的体系结构,因为它的行为与任何其他基于文档的应用程序非常相似,除了单窗口之外。
由于 NSDocument
必须 (根据文档)有自己的窗口控制器,是否可以将该窗口“嵌入”到另一个窗口中(即在我的项目窗口中),使镀铬不可见以提供单个窗口的效果?
编辑:关于 CocoaDev 的讨论看起来非常有用: 基于文档的应用程序,具有一个窗口显示所有文档
I have a document based application, that so far simply edits documents with a new window for each document.
I'm now adding the ability to create a project, which is a document in itself. That project will contain a list of files that can be edited using (hopefully) the same code as my existing NSDocument
subclass, with the exception that the document editor will be embedded into the project window, not opened in a new window.
How does Xcode, for example, open each file in the editor pane, without using a new window per document? I assume it uses the document-based architecture since it behaves much like any other document-based application with the exception of the single window thing.
Since an NSDocument
must (according to the documentation) have it's own window controller, is it possible to "embed" that window inside another window (i.e. inside my project window), making the chrome invisible to give the effect of a single window?
EDIT: This discussion on CocoaDev looks really useful: Document Based App With One Window For All Documents
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然这是一个长期存在的问题,但因为我最近(并且仍然)处于同样的情况并且找不到任何有用的解决方案来解决这个问题,我自己启动了一个测试平台项目并将其托管在 Github 上: https://github.com/lemonmojo/NSDocumentSingleWindowTest
它仍在进行中,但最重要的部分就在那里,等待改进。
您应该能够轻松地提取项目所需的代码。
Obviously this is a long standing questions but because I recently was (and still am) in the same situation and couldn't find any useful solutions to the issue I started a testbed project myself and hosted it on Github: https://github.com/lemonmojo/NSDocumentSingleWindowTest
It's still a work in progress but the most important bits are there, waiting to be improved.
You should be able to extract just the code you require for your project pretty easily.