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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to