bug-gnustep
[Top][All Lists]
Advanced

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

Re: [Bug #3346] NSDocument actions are not reachable


From: Stefan Urbanek
Subject: Re: [Bug #3346] NSDocument actions are not reachable
Date: Po, 28 Apr 2003 12:43:58 +0200

Hi,

I am moving it to the list...

On 2003-04-28 12:15:21 +0200 nobody@savannah.gnu.org wrote:

------------------ Additional Follow-up Comments ----------------------------
No - the methods should be implemented only in NSDocument.
There is a precise reason for this - when you subclass NSDocument, you might 
want to add new methods other than save/close.  Those methods should be 
immediately available
to the main menu without the need of wrapping them manually
in NSWindowController/NSDocumentController.


ok

It fits in the general philosophy that actions of the active
objects are activated and can be called directly from the menu.  That makes 
simple to add new actions to objects which
can be active, and new menu items calling those actions without modifications 
of other parts of the software.


hm, true.

The problem you are having is definitely due to not setting
up correctly the various connections required in NSDocument-base applications.  
Those connections *are*
confusing to set up; Apple seems to have targeted too much flexibility at the 
expense of simplicity.


so how do i have to set up connections?

I have:

- my own app controller as application delegate (NSObject subclass) where i do 
nothing NSDocument* related (at this time)
- Info.plist with NSTypes and defined NSDocumentClass
- subclass of NSDocument - MyProject
- subclass of NSWindowController as MyProjectController
- gorm file with standard Document menu whichc sends newDocument: and 
saveDocument... to the first responder

The document creation is as follows (from my point of view, without internals):
1. 'New' action from menu goes into responder chain
2. Instance of MyProject is created by AppKit
3. I handle creation of window controllers as follows:
 - (void)makeWindowControllers
 {
     MyProjectController *controller;
        controller = [[MyProjectController alloc] init];
     [controller setDocument:self];

     [self addWindowController:AUTORELEASE(controller)];
 }
4. I have MyProject.gorm with a window, NSOwner is MyProjectController and 
there are connections:
   NSOwner.window -> my window
   my window.delegate -> NSOwner

5. In MyProjectController:NSWindowController i have:
 - init
 {
     return [self initWithWindowNibName:@"MyProject"];
 }
 And I have implement writeToFile:ofType: in MyProject as documented by docs. 
That is all. I was digging through documentation and this seems to be enought 
to have.

Without source code of what you have done, it's difficult to guess what needs 
changing, so I'll point you to examples
instead:

I'm not sure if Ink (gui-only version) is right - it's a while I don't look at 
it; but the Renaissance version of Ink (included in the Renaissance example 
applications)
is definitely right and it works (on both GNUstep and Apple OS X).

Renaissance also uses both a customized NSDocument and NSWindowController in 
order to support loading nib files
from .gsmarkup rather than .gorm; you might take that as
an example of using both customized.


I am using Gorm.

This problem was reported by others on #gnustep, who followed docs and got same 
behaviour (that means, no behaviour at all). What I am missing in my code?

Stefan





reply via email to

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