Lucidus
Lucidus

Reputation: 161

In cocoa, how can I close (quit) the main window but keep the status item running?

In my cocoa app, I have a main window to display main content. Also there's a status item in system status bar (top right) to receive event after the main window is closed.

When I press cmd+q in my app, the main window and status item all quit. How can I make the status item part keep running?

Upvotes: 0

Views: 409

Answers (2)

lbrndnr
lbrndnr

Reputation: 3389

there are 2 options.

  1. You seperate the normal application with the window and the statusbar.

  2. You only hide the window. You can create a new action (for example called -(IBAction)hideWindow;) and connect it with the "terminate NSMenuItem" in the MainMenu (with Interface builder)

Upvotes: 0

gcamp
gcamp

Reputation: 14662

You need to have a different application that shows the status item.

One application would run constantly and show the item.

The other is the principal application, running when you need it.

Upvotes: 2

Related Questions