Eimantas
Eimantas

Reputation: 49354

Deactivate agent app after launch in Cocoa

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.

Upvotes: 1

Views: 1529

Answers (2)

Dave DeLong
Dave DeLong

Reputation: 243156

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:.

Upvotes: 2

Darren
Darren

Reputation: 25619

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.

Upvotes: 1

Related Questions