4

I'm writing a mac app that sits in the menu bar and presents the user with a NSPanel instance when they click the status item. I want to hide the window whenever another status item's menu is opened. Right now, my panel stays open; it looks like this:

My app is on the left, attached to the infinity status item

I see other applications like mine close when another status item opens its menu, so I'm wonder which notification they're getting to know to disappear. I've looked into NSWindowDelegate and NSApplicationDelegate, but I don't see any notifications being generated.

Have any suggestions?

Ash Furrow
  • 12,391
  • 3
  • 57
  • 92

1 Answers1

4

I figured it out! In the awakeFromNib, I was setting the properties of my NSPanel instance. I was using the following:

[panel setStyleMask:panel.styleMask ^ NSTitledWindowMask];

Switching it to the following:

[panel setStyleMask:(panel.styleMask ^ NSTitledWindowMask ^ NSNonactivatingPanelMask)];

Did the trick. I figured it out after reading Neil Inglis' blog post on using MAAttachedWindow in a similar way.

Ash Furrow
  • 12,391
  • 3
  • 57
  • 92