User Notification Opens another NSStatusItem menu on Mac

I am writing a mac application that is on the menu bar and presenting the user with an NSPanel instance when it clicks on the status item. I want to hide the window whenever another status menu opens. Right now my panel remains open; it looks like this:

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

I see other applications, like mine, when another status item opens its menu, so I'm wondering what notification they will know in order to disappear. I looked at NSWindowDelegate and NSApplicationDelegate , but I don't see any generated notifications.

Are there any suggestions?

+4
source share
1 answer

I understood that! In awakeFromNib I set the properties of my NSPanel instance. I used the following:

 [panel setStyleMask:panel.styleMask ^ NSTitledWindowMask]; 

Switch to the following:

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

Did the trick. I realized this after reading a Neil Inglis blog post about using MAAttachedWindow in a similar way.

+4
source

Source: https://habr.com/ru/post/1398643/


All Articles