On Thu, Mar 4, 2010 at 6:35 PM, Kyle Sluder <kyle.slu...@gmail.com> wrote:
> On Thu, Mar 4, 2010 at 9:05 AM, fabian <cocoadevl...@gmail.com> 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 (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