Reputation: 51
I'd like to set disable highlighted mode of NSStatusItem
when clicked. In OS X 10.10 and later version, highlightedMode
property has been deprecated, and Apple suggest using button
property. So, what's the equivalent of setHighlightedMode:
? Swift or Objective-C is OK.
Thanks in advance.
Upvotes: 3
Views: 601
Reputation: 90641
Get the button's cell, cast as an NSButtonCell*
, and set its highlightsBy
property to 0. Of course, that involves cells, which are also being gradually deprecated.
Internally, -[NSStatusItem setHighlightMode:]
calls -[NSStatusBarButton setHighlightMode:]
, which calls -[NSStatusBarButtonCell setHighlightMode:]
. That last calls -setHighlightsBy:
on itself with either 0 or NSContentsCellMask | NSChangeBackgroundCellMask
, depending on the mode. Unfortunately, neither -[NSStatusBarButton setHighlightMode:]
nor NSStatusBarButtonCell
are public API, so the best you can do is emulate them.
All told, it's probably best to just keep using -[NSStatusItem setHighlightMode:]
and file a bug report with Apple requesting a non-deprecated approach.
Upvotes: 1