NSVisualEffectView for NSScrollView

I am trying to get my NSScrollView (and therefore containing NSOutlineView ) to use the blurry NSVisualEffectView shutter blending effect.

I successfully made the NSVisualEffectView container view and placed the scroll view as a subtitle. This seems to work fine (as long as I make all of my tables, tables, nsscrollview, etc. transparent).

However, now I have enabled “Reduce Transparency” in the “Accessibility Options” section, and suddenly I have a black background behind my NSScrollView . I tried to subclass the visual effect to override the drawRect method so that I could paint my own background, but I just found out that this is not possible or recommended.

How do I determine if the Reduce Transparency feature is enabled, and how do I dynamically scroll the scroll dynamically?

+6
source share
2 answers

It took me a while to find it, but there are a few new methods on NSWorkspace that you can use to learn about preferences for the new X Yosemites OS accessibility features. -[NSWorkspace accessibilityDisplayShouldReduceTransparency] is the one you want.

NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification listening to NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification , you can find out when this preference changes. Note that you need to register this notification with the correct NSNotificationCenter , that is, [[NSWorkspace sharedWorkspace] notificationCenter] .

+6
source

It seems that at the moment I have finished redefining the parent NSView , which contains everything and sets the background color for it. That way, when the “Decrease Transparency” function is turned on, the NSVisualEffectView becomes transparent, and the color that I get is the one that appears below it. This is currently working fine.

+1
source

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


All Articles