10.4 System Preferences Cannot Find Its Main Window When Launched by a Pane Bundle
10.4 System Preferences Cannot Find Its Main Window When Launched by a Pane Bundle
- Subject: 10.4 System Preferences Cannot Find Its Main Window When Launched by a Pane Bundle
- From: Grant Erickson <email@hidden>
- Date: Wed, 28 Oct 2009 16:18:16 -0700
- Thread-topic: 10.4 System Preferences Cannot Find Its Main Window When Launched by a Pane Bundle
I am working on a preference pane and in order to accommodate differences
among 10.4 and 10.5 and later without hard-coding widths, I call my own
[self resizeView] from mainViewDidLoad to adjust the view width as
appropriate:
- (void) resizeView
{
NSRect viewFrame, windowFrame;
NSWindow * mainWindow = NULL;
viewFrame = [[self mainView] frame];
mainWindow = [[NSApplication sharedApplication] mainWindow];
if (mainWindow != NULL) {
contentFrame = [mainWindow contentRectForFrameRect: [mainWindow
frame]];
viewFrame.size.width = contentFrame.size.width;
[[self mainView] setFrame: viewFrame];
}
}
Overall, this seems to work well; however, when testing automatic updates
with Sparkle, I noticed that when Sparkle relaunches the bundle
("/Library/PreferencePanes/MyPane.prefPane") using its 'relaunch' binary
(which in turn uses NSWorkspace), that [[NSApplication sharedApplication]
mainWindow] returns NULL.
In fact, when I check [[NSApplication sharedApplication] mainWindow] in all
of:
* initWithBundle
* mainViewDidLoad
* willSelect
* didSelect
it is always NULL. Removing Sparkle from the loop, I can recreate the
problem using the 'open' shell executable:
% open /Library/PreferencePanes/MyPane.prefPane
Anyone else seen this behavior or developed a reasonable workaround? Perhaps
registering for and resize on NSWindowDidBecomeMainNotification?
Regards,
Grant
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden