Re: Sheet & Window Questions
Re: Sheet & Window Questions
- Subject: Re: Sheet & Window Questions
- From: Emma Whan <email@hidden>
- Date: Fri, 28 Feb 2003 23:39:42 +1100
I think you need to provide more information on why the application
fails to respond correctly. Is it a document-based application? If
so, is the problem that the sheet code affects both windows (or
documents) when it is not meant to? If that is the case, you should
get your sheet code to check which window/document sent the controller
the notification and then write the code so that it only affects that
window/document.
Re your other question, I think it usually best to put different
windows in different nib files. This is what Hillegass recommends in
Cocoa Programming for OSX because it makes it easier to re-use nib
files in other applications. The best way to open a new window also
varies depending on whether you are just creating a new document (with
its own window) or are opening a new type of window for an existing
document or a new type of window in a non-document application.
For example, if I make a non-document based application and I have a
main window and a preferences window, I put the preferences window in a
separate nib file (although this isn't necessary) with its own
controller (a subclass of NSWindowController) and put a variable of the
preference controller's class in my main controller. If I called that
variable preferenceController, then to open the preferences window I
would simply use the following code:
if (!preferenceController)
preferenceController = [[PreferenceController alloc] init];
[preferenceController showWindow:self];
I don't release that preference controller until quitting the app.
Only one of them can exist at a time anyway.
The situation is different if you have a document-based app with more
than one window per document. Read the developer documentation re
implementing a document-based application in that case.
>
From: "Eric Czarny" <email@hidden>
>
To: <email@hidden>
>
Subject: Sheet & Window Questions
>
Date: Thu, 27 Feb 2003 13:28:14 -0500
>
>
In the application that I am developing I would like to use custom
>
made sheets
>
to notify the user of errors. To reduce the amount of code I was
>
thinking
>
about using notifications to drop the sheets and keep the actual sheet
>
code in
>
the main application controller. The main problem with this
>
implementation is
>
that if the window the user is on drops a sheet and the user choses to
>
work
>
with another window and IT drops a sheet as well, the application
>
fails to
>
respond correctly. Is there a way in which I could make any other
>
window open
>
not receive mouse clicks? Is there a better way I could use custom
>
sheets in
>
my application?
>
>
The second question I have is in regards to windows. What way do you
>
open a
>
new window? There seems to be a number of ways in which to accomplish
>
this
>
task, but what is the best way to do it? Would it be best to use one
>
NIB file
>
or seperate ones?
>
>
I know I have a lot of questions, but there just isn't an explanation
>
for
>
these questions in anything I have read, perhaps a few of you could
>
help me
>
out?
>
>
Best Regards,
>
Eric Czarny
>
>
http://www.laterus.net
_______________________________________________
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.