Re: Uninitialized rectangle??
Re: Uninitialized rectangle??
- Subject: Re: Uninitialized rectangle??
- From: fabian <email@hidden>
- Date: Thu, 4 Mar 2010 18:49:02 +0100
On Thu, Mar 4, 2010 at 6:35 PM, Kyle Sluder <email@hidden> wrote:
> On Thu, Mar 4, 2010 at 9:05 AM, fabian <email@hidden> wrote:
> > It's in -applicationDidFinishLaunching. Which works great on all systems
> (as
> > far as I know), except for on 10.5.8 where NSStatusBar is still nil at
> this
> > point. That's what I'm trying to find a work-around for.
>
> From the -[NSApplication finishLaunching] docs: "The run method
> invokes this method before it starts the event loop."
>
> Doing AppKit stuff without an event loop always makes me nervous.
> Perhaps AppKit is doing some delay-perform stuff, or is waiting on a
> runloop input source from the menu manager or window server, or
> something else.
>
> You're right, this sounds like something that should Just Work.
>
> --Kyle Sluder
>
One thing that occurred to me: the only non-magical thing that differs
between first run (display dialog, everything works as expected) and second
run (no dialog, no go), is that the app is activated on first run before
putting up the dialog. On second run it is not explicitly brought to front.
Is there any chance adding a [NSApp activateIgnoringOtherApps:YES] statement
in -applicationDidFinishLaunching, just before getting the status bar, could
make a difference? This is a faceless agent, btw.
My code:
- (void) awakeFromNib
{
if ( [[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"] )
{
// if this code is executed on 10.5.8, everything works fine. If
not, assertion failure...
[NSApp activateIgnoringOtherApps:YES];
[[NSAlert alertWithMessageText:@"Hello" defaultButton:@"OK"
alternateButton:nil otherButton:nil informativeTextWithFormat:@"Welcome"]
runModal];
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
statusItem = [[statusBar statusItemWithLength:26] retain];
NSRect frameRect = [[statusItem view] frame];
MyStatusItemView *theView = [[MyStatusItemView alloc]
initWithFrame:frameRect];
[theView setDelegate:self];
[statusItem setView:theView];
[theView release];
}
_______________________________________________
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