Popup Window for StatusBar Item - cocoa

I'm building an Application and it needs to have a status bar item and a custom popup window, that popups when the status bar item is clicked.
I know how to set up a status bar item and a nsmenu for it, but I need a custom window rather than a nsmenu.
An example for what I'm looking for would be Take Five by the IconFactory
I really hope you have any ideas how I can do it.

Checkout the following example project by Matt Gemmell:
Using MAAttachedWindow with an NSStatusItem
Screenshot:

Related

Swift - NSMenu closes when clicking outside of menu

so i have a simple NSMenu. It is attached to a Status Item Button.
When i click the Button it pops Open.
Now my Problem is that as soon as i click outside of the NSMenu, it closes. How can i avoid that ?
I did try many things but cant get that to work.
The reason i need that is that when the user clicks something in the NSMenu, another window opens, and while this window is open i also want the NSMenu to stay open. But it just does not work.
I feel like its impossible.
Many Thanks in advance.
I believe you have to create a custom view that pops up but something that could be done natively with just NSMenu.

StatusItem menu doesn't open on hover

I've got an NSStatusItem with a menu. My problem is that when you click on for example the wifi icon, the menu appears. When I move to the right (on my mac the battery status item is there) the menu for the battery automatically appears. That's what I mean with "on hover". This behaviour is implemented in pretty much all status items and/or menu's. But my NSStatusItem doesn't implement this behaviour. I don't see an option in IB to "assign" this behaviour, so I started searching the web and all I can come up with is this:
Status Item menus don't open on hover
The "answer" here is everything but satisfying. So my question is: is this true? Aren't there any ways to create this behaviour without using private API's?
Thanks a lot in advance,
Frans

update statusbar menu on click mac os x cocoa

I've been playing around with a statusbar menu app and what I'd like it to do is to update the content of the menu when it is clicked. I've been able to get everything working on the awakefromnib function and it works as expected. Now i just want to update the menu everytime I click on the status bar. This surely can be done, since it's done in the dropbox statusbar menu and many of the native app statusbar menus. I'm not able to associate a action directly with the click of the menu and I don't want to leave a loop running in the background cause I don't really see a need for it. Any ideas? An alternative would be to have an action associated to a menu item which does not cause the menu to get hidden again. Any help would be welcome.
Just set a delegate for your menu, and implement the -(void)menuWillOpen:(NSMenu *)menu method.

How to display my app's icon (programmatically) on the top right corner of the Mac OS X menu bar

I know Skype does it - they have a special icon register to there. And then when user click on the icon, a drop down menu will appear...
See the docs for status bar and NSStatusItem. You can also find tutorials and sample code by googling for NSStatusItem.
NSStatusItem is responsible for this.

how do you display an NSMenu programmatically?

I wrote a little app that lives in the NSStatusBar. I want to have a global shortcut that when hit, the menu bar's content is displayed, exactly like the behavior of spotlight.
I have added a global key shortcut to my application, but I am unable to get the meun bar to display. How can I do this? I tried with "popUpContextMenu" , but that method displays the menu in the bottom left hand corner, I want the menu to open up right under the NSStatusBar menu icon.
You can do it, apple provides a method for it popUpStatusItemMenu:
I don't think there is a supported way to do this without perhaps using the Accessibility framework to simulate a click on your status item. Regardless, it's probably not a good idea to abuse a menu in this way.
The Spotlight menu bar item does not use an NSMenu, it uses a custom window/view. You might consider going this route if you have some sort of custom view to display.

Resources