I have a NSDocument document. The document is composed of card collections which
can be of different types. There is a document window (NSWindowController +
NSWindow) and in that window are two parts: one list for adding and removing
collections, and a view for editing the collection:
+-------+-------------+
| | |
| list | view |
| | |
|[+][-] | |
+-------+-------------+
When there was only one type of collection, there was no problem, as the view
was the collection view and the window controller served as editor (delegate),
which handled all action methods too.
Now I have more collection types and I would like to have different view for
each type. Say, that I have following types: ordered stack collection and
diagram. The view for ordered stack would be something similar to the view in a
presentation application (PowerPoint or OO.org) where one sees all slides and
can reorder them by D&D. The diagram view will look like, well, a diagram :o) -
objects with connections.
Now I would like to change the view, depending on the selected collection. And I
would like to have separate object to handle all editing actions - move editing
out of the window controller, as there should be many kinds of editors in the
future.
One solution is to have an Editor class which will provide a view. Then window
controller will reference: currentEditor, editorView. When one selects a
collection, the window controller will do:
- notify old editor that it will end editing
- remove old editor
- create new editor according to the collection
- assign selected collection to the new editor
- change old editor view to new editor view
Now, the problem is: how can I include the new editor object into the responder
chain?