NSStatusItem icon

Hi guys, I’m looking for a little help with an NSStatusItem app. My handler for the NSStatusItem doesn’t open a menu. Instead, I have it set up to open a custom window. This is no problem but I’d like the NSStatusItem icon to stay highlighted after it’s clicked and while the window remains open. I am using MacOSLib.

Thanks for any pointers.

Try ShowModal.

Well I’ll be buggered… It looks like Apple are doing away with the NSStatusItem, with 90% of functionality deprecated in Yosemite :frowning:

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusItem_Class/index.html

Until I read that, I was going to suggest using a custom view, this way you can draw the selected background when you want. However there is no guarantee that it’s going to work in a future version.

Whoa, NSStatusItem is really changing.

from these release notes
https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/

Apples docs aren’t updated to show this -button property but I did find it in the headers

@property (readonly, strong) NSStatusBarButton *button NS_AVAILABLE_MAC(10_10);

along with the comment

[quote]/*
Custom views should not be set on a status item.
The button property with a template image will allow proper styling of the status item in various states and contexts and should be used instead.
*/[/quote]
(My headers are out of date and NSStatusBarButton only shows one boolean property.)

This SO post has an idea how to work with -button for a similar keeping-it-highlighted situation

Yeah, it seems to be mostly passed on to NSStatusBarButton, as Will says. It’s only deprecated though, a quick test shows the old NSStatusItem functionality is fine for now in El Cap.

[quote=203857:@Will Shank]This SO post has an idea how to work with -button for a similar keeping-it-highlighted situation

Thanks Will, this looks like my best shot.

I can confirm that with PB3 it does still work, but that doesn’t mean that come GM it will. With Yosemite Apple changed a couple of things with the GM, okay they removed some system icons that my app was using! Wasn’t impressed as my app was working during the DPs but then I get a bunch of crash reports once GM ships.

Hopefully this year it’ll be better.