Preferences Panel
Preferences Panel
- Subject: Preferences Panel
- From: Albion Baucom <email@hidden>
- Date: Thu, 15 Jul 2004 13:35:47 -0700 (PDT)
Thanks to those who answered my questoins about commuicating with objects
instatiated by a NIB. I broke through my conceptual roadblock and have a
much firmer grasp on Cocoa communication, but evidently not completely ...
I have two questions about displaying a preferences panel for a document
based application.
1. I can't get the panel to display. I created a preferences panel in IB,
and made its file owner "Preferences". I have a Preferences.m and
Preferences.h file in my Xcode project. I created an outlet for a
NSWindowController (preferencesPanelController), and an outlet for a
NSPanel (preferencesPanel) and connected them via IB in the Preferences
NIB, and the preferences menu option in my MainMenu NIB.
So, when I try to open the preferences via the menu option, I see that my
method is called; "showPanel called" is printed, but the panel never
appears. I don't get an error, I have tried inside and out of the if()
statement checking if the preferencesPanelController has been
instantiated, and the NSLog shows a healthy NSWindowController object.
My Preferences.nib file lives in the same directory in the project as the
MainMenu.nib file, and I never get an error that the NIB failed to load.
Here is the showPanel code that I have connected to the "Preferences ..."
menu option
- (IBAction)showPanel:(id)sender
{
printf("showPanel called\n");
if(!preferencesPanelController)
{
if (![NSBundle loadNibNamed:@"Preferences" owner:self])
{
NSLog(@"Failed to load Preferences.nib");
NSBeep();
return;
}
preferencesPanelController = [[NSWindowController alloc]
initWithWindow:preferencesPanel];
NSLog(@"preferencesPanelController %@",
preferencesPanelController);
}
[preferencesPanelController showWindow:self];
}
In IB, you can use a "Window" or a "Panel" as a preferences panel. I chose
the Panel widget. Would that make a difference, which I used?
2. Once I get a preferences panel to display, I have to direct its actions
at the currently active document window, or if the user chooses, all
currently open windows. How do I go about targeting the active window, or
all of them simultaneously?
Thanks
Albion
Albion E. Baucom
http://rna.ucsc.edu/albion
_______________________________________________
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.