Re: Programatically opening an NSDocument subclass ??
Re: Programatically opening an NSDocument subclass ??
- Subject: Re: Programatically opening an NSDocument subclass ??
- From: Robert S Goldsmith <email@hidden>
- Date: Mon, 17 Sep 2001 14:58:32 +0100
Hi :)
I don't know much about NSDocument applications but I do
know the following:
You can open the open and save dialogs, either as modal
sheets or as sheets not attached to a window, using the
NSOpenPanel calls. Create an NSOpenPanel object with certian
settings will give it as a seperate window and if you want
it as a sheet appearing attached to a window, you use a
similar method that uses a callback to return the result of
what the user selects. Examples are in the documentation for
NSOpenPanel.
NSOpenPanel returns an NSString object which you can pass in
a call to your NSDocumentController's methods such as
OpenDocumentWithContentsOfFile:display: (and others).
as a side note, if you don't want to use the
NSDocumentController, NSApplication can be delegated to
respond to application:openFile:. This is also the method
called when a user doubleclicks on a file or drag-drops a
file onto your application (at least if you don't have an
NSDocumentController - I think).
Robert
Robert Miller wrote:
Hello,
This is probably a very basic question but, I have an application
that opens different types of subclassed NSDocuments. I want to be able
to select a file to open (NOT using the standard File/Open... menu item)
and displays its contents in the appropriate NSDocument subclass. I have
an IBAction stub implemented which calls a method in my AppController
class. At tha point I'de like to present the user with a file selection
dialog and then open a doc if the user selects a file. The example code
provided seems to assume that any application has a matching nib file
for the document and its window. The execution of this default behaviore
seems to happen 'magically' through the NSApplication object when the
standard File/Open menu item is used. How would I go about implementing
the same standard behavior in my own custom menu item ? are there any
eamples available ?
Thanks in advance,
Regards,
Bob M.
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev