Re: Preferences Panel: No Progress
Re: Preferences Panel: No Progress
- Subject: Re: Preferences Panel: No Progress
- From: John Pannell <email@hidden>
- Date: Fri, 16 Jul 2004 14:23:51 -0600
Hi Albion-
I have a similar setup as far as IB is concerned, but my code is
different. In my app controller, I call the following method to launch
the prefs window:
- (IBAction)showPreferencePanel:(id)sender
{
// is preferenceController nil?
if(!preferenceController){
preferenceController = [[PreferenceController alloc] init];
}
[preferenceController showWindow:self];
}
The preferenceController object is the NSWindowController subclass. In
the init method for the preferenceController object, I have the
following:
- (id)init
{
self = [super initWithWindowNibName:@"Preferences"];
return self;
}
Thus, the controller is alloc'ed and init'ed, the nib is hooked up to
the correct object in the process, and then the controller is told to
show its window. In your code, I believe you erroneously set the owner
of the nib-based window to the appController, then attempt to assign a
window object from that nib to the NSWindowController. If I understand
your IB setup correctly, "File's Owner" is expecting to be an
NSWindowController, not the appController (or whatever your are calling
your main controller object).
Please give the above code a try (changing names to match your
conventions) - it works like a charm for me!
HTH!
John
On Jul 16, 2004, at 1:31 PM, Albion Baucom wrote:
>
Im still getting no where with this one. Help.
>
>
This is a document based application, so the NSWindowController stuff
>
is a
>
little more complicated.
>
>
1. I can't get a preferences 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.
>
>
(follow-up: I have checked, double checked my connections. I looked at
>
the
>
developer example TextEdit that has a preferences panel, and the
>
"accessory" window example in my Learning Objective-C with Cocoa book).
>
>
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];
>
}
>
>
>
Could this be opening offscreen?? There is simply no errors generated,
>
and
>
this code on the first call prints this
>
>
showPanel called
>
2004-07-16 12:26:27.888 MOViewer[557] preferencesPanelController
>
<NSWindowController: 0x147c9d0>
>
>
and on subsequent calls I get just this
>
>
showPanel called
>
>
All is normal, EXCEPT THAT THE WINDOW NEVER IS DISPLAYED! Ahhh. I have
>
spent a lot of time trying to figure this one out. I may just start a
>
test
>
project to see if I can write code to make any window appear. The
>
examples
>
work fine, but I can't find the difference between their code and mine
>
(either in Xcode or IB).
>
>
What am I missing?!
>
>
Thanks
>
>
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.
_______________________________________________
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.