How to access the system selected menu item blue color?
Asked Answered
M

2

29

I'm working on an app that has a custom NSView on a NSStatusBar which performs all of the drawing when the user clicks it. But here's the problem, the color I'm currently drawing as the view's background color is not the same as the system blue color.

My app's color:
enter image description here

Twitter's menu item color (system):
enter image description here

As you clearly see, my blue color is way lighter than the system. This is the code I'm currently using (and worked perfectly on versions older than Yosemite):

[[NSColor selectedMenuItemColor] set];
NSRectFill(rect);

I've even tried color picking the menu item's color but it seems like the color is affected by the wallpaper below the menu bar.
Any ideas on how to achieve the system look?

Meatus answered 4/4, 2015 at 4:4 Comment(2)
Are you sure Twitter is using selectedMenuItemColor? Maybe they are use something diffrent?Cimon
I was just showing an example that uses the system color for selected menu bar items, and twitter uses the same color as the other built-in widgets, like Wi-Fi and battery. I've been using selectedMenuItemColor on older versions of OS X and always worked as expected, not on Yosemite though.Meatus
G
6

As you said, in Yosemite, docks, status bars etc. are affected by whatever is behind them. Try enabling System Preferences > Accessibility > Display > Reduce Transparency and you'll see what your color looks like without this feature./

Gam answered 14/4, 2015 at 10:27 Comment(2)
That seemed like a great idea but unfortunately that doesn't work. When I turn it on again the colors are way off.Meatus
i meant to say, turn it off (the reduce transparency)Meatus
K
2

Here is an idea - Maybe you should use the Vibrancy effect and derive from NSVisualEffectView. I knew that I've seen a very similar thread somewhere here in the past, and it took me quite some time to find it. Here it is:

Trouble matching the vibrant background of a Yosemite NSMenuItem containing a custom view

I think Matthes' answer to that question would lead you to the resolution of your issue. Be sure to check it out. I hope it will help - Good luck and report back!

Knowledgeable answered 3/5, 2015 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.