Re: Best way to implement a modal window
Re: Best way to implement a modal window
- Subject: Re: Best way to implement a modal window
- From: Charles Srstka <email@hidden>
- Date: Mon, 5 Apr 2004 04:14:23 -0500
Yeah, your needs may be different than mine. In my case, I do this
while I'm loading a document which exists and populating its data
structures prior to displaying it on screen.
Hmm, maybe you could override newDocument: in an NSDocumentController
subclass and have the button call a method which calls
openUntitledDocumentOfType:display: ?
Either that or you could use NSApplication's delegate method
applicationShouldOpenUntitledFile:, although I've found there are a few
instances where this will get bypassed and a document will just get
created, so the NSDocumentController subclass may be your best bet,
unless anyone can come up with a better idea.
Charles
On Apr 5, 2004, at 3:21 AM, Christoffer Lerno wrote:
But then, it the user cancels the dialog, the NSDocument still get
created, it's just that it hasn't an UI, right?
One suggestion would be to wire the main menu "new" to a dialog that
later calls newDocument...?
/C
On Apr 5, 2004, at 15:14, Charles Srstka wrote:
What I do is to call this method at startup:
[[NSDocumentController sharedDocumentController]
setShouldCreateUI:NO];
Then, I just create the window controllers myself when I'm ready to
display the document's window.
Someone may have a better solution - that's just what I do.
Charles
On Apr 5, 2004, at 1:11 AM, Christoffer Lerno wrote:
If I press New in the menu, it will issue a newDocument: in the
NSDocumentController, and the NSDocumentController in turn will
allocate(?) and initialize my ScenarioDocument (an NSDocument
subclass)... right?
Now where in this chain do I put the Panel to pass on the right
parameters to ScenarioDocument? Init doesn't accept any parameters,
so it's up to me to initialize those values after init. If I
subclass NSDocumentController I could set up something to stop
newDocument from initializing NSDocument and instead pass things
over to the Panel which in turn creates the NSDocument if all the
arguments are nice?
/Christoffer
On Apr 5, 2004, at 12:16, Charles Srstka wrote:
On Apr 4, 2004, at 9:41 AM, Christoffer Lerno wrote:
For my editor, I'm planning on using NSDocument to structure
things. Now, being new to cocoa, I quickly ran into a small design
problem. It's not that I can't make it work, it's just that I want
it to be a good design too.
This is what is supposed to happen:
1. User clicks New in the menu
2. A modal window appears, asking for the width and height of the
map
3. If width and height is correct, pressing the button labeled
"create" will close the modal window and open a new window laid
out with the requested width and height.
How do I design this best? For example, what class should be
handling the modal window's stopModal request?
My original design (before adding the modal window) looked like
this:
ScenarioWindow (NSWindow)
ScenarioDocument (NSDocument subclass)
ScenarioWindowController (NSWindowController subclass)
Sure, I could put an action in ScenarioWindowController for my
NewDocumentPanel's "create" button to connect to when it wants to
close, but that doesn't seem like it's responsibility. Another way
could be to simply add that functionality to NSPanel, and yet
another to make a Controller for the panel (but that seems like
overkill).
What's the best design?
There is no reason to use a modal window for this. Just use a plain
old window with the "Create" button set to finish making the
document.
Charles
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.