views:

151

answers:

2

What method should be called to deactivate an app right after it's launch in applicationDidFinishLaunching: delegate method has been called? Or maybe there is a better place to do that? The documentation for deactivate method for NSApplication says that I shouldn't call this method directly since AppKit knows better how to deactivate stuff.

+1  A: 

It's not clear what you're trying to achieve.

You can use -hide: to deactivate your app. I also wouldn't hesitate using -deactivate if it actually does what you need. It's just that normal applications do not explicitly deactivate themselves; I think that's what the documentation is saying.

However, if you set LSUIElement in Info.plist your application should not become active when launched; it also won't have a menu bar or dock icon.

Darren
App does become active after launch, since I added global event monitor and i get beeps each time i press the global key registered in global event monitor.Global event monitors don't route events to the app while it's being active. Right?
Eimantas
+1  A: 

Maybe using -[NSApplication hide:] would work, or perhaps activate another app using -[NSRunningApplication activateWithOptions:] (10.6 only, tho). However, I don't foresee many problems with using deactivate:.

Dave DeLong
I think i'll try with NSRunningApplication approach. Thanks a heap!
Eimantas