discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Editor and the responder chain


From: Fred Kiefer
Subject: Re: Editor and the responder chain
Date: Mon, 21 Mar 2005 14:35:55 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040906

Stefan Urbanek wrote:
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?


I did not understand at what layer you use the document class. Is one diagram a separate document or constitute all diagrams together the document? From what you descirbe I would expect the later and this also fits better with the NSDocument paradigma.

I see different things you could do. One being to have a specific NSView subclass used as the editor which will be in the view hierarchy and by that also in the responder chain. This is a solution I don't like much.

A better way would be to make the editor the delegate of the window, whenever you change the diagram. This puts it into the responder chain, and every class still may have its natural super class.

Fred





reply via email to

[Prev in Thread] Current Thread [Next in Thread]