Yosemite: Manage NSPopover’s Vibrancy Effect - cocoa

With the OS X 10.10 SDK, NSPopover seems to default to including an NSVisualEffectView somewhere in its hierarchy. Trouble is, I can’t seem to find any way to manage the effect.
I’ve tried the Xcode View Debugger but that didn’t offer very much information:
Are we expected to be able to tweak this vibrancy or just accept it and move on?
I wouldn't mind being able to tweak the effect or change the appearance of certain items in the (apparently enforced) dark mode.

It appears that you need to set the NSPopover's appearance property to an instance of NSAppearance.
There are a number of standard appearances including both light and dark vibrancy, along with a allowsVibrancy property for custom appearances.
While the documentation for the vibrance appearances says:
This should only be set on an NSVisualEffectView or one of its subviews.
The NSPopover documentation doesn't appear to have been updated (the comment for appearance still references the NSPopoverAppearance enum), so it is probably worth a shot.

Related

NSImageViewl Highlighting/Selection

(using Xcode 8b0 on 10.11.5, but the problem also occurs under 7.3)
My app uses an NSColorWell and two NSImageWells to allow users to set a background (colour, image, pattern). The colourWell behaves just fine. The two image wells do not: if you click on one, it will be selected and it is impossible to deselect both (which is what I want if I am using the colourWell.)
NSImageView does not have a deactivate or deselect method. isHighlighted is false even when the imageWell is clearly marked as selected; setting the highlight on either the imageWell or its cell has no visual effect.
The memory of selection persists even between restarts of the app which makes me think it must be stored in the storyboard somehow, only I cannot work out which property is responsible (I've read through the documentation for NSImageView and NSControl without luck).
By employing a ridiculous dance of disabling and enabling my image wells in specific order (you need to enable the one you want to show up as selected first) combined with subclassing NSImageView to override 'mouseDown' so it sends a notification that I capture to trigger the imageWell's action I have got the behaviour I want, but I would really appreciate an easier way of doing this since 'enable/disable controls in specific order' feels like a hack. (So, alas, feels adding the appropriate drag-and-drop support to a NSButton; I really like the 'drop image, have background change' functionality).
Who or what is causing my NSImageViews to be highlighted and how can I take control of this behaviour?
The answer is that this is not a highlight, which is why setting isHighlighted to false does nothing at all. NSImageView has a property named allowsCutCopyPaste- and if this is set to 'true', the imageWell - or the currently active imageWell if you have more than one - will show this 'highlight'.

Set color of NSStatusItem OSX 10.10 Swift

I have seen that some icons in the Menu Bar have colours, but I can't find a way to color the NSStatusItem I'm working on. I use an image (inside Images.xcassets) with color, but it just tints in white or black. I'm using MacOS 10.10 and Swift. I have also searched Apple documentation with no luck.
Thanks for your time.
Those status items with color are actually doing it the wrong (old) way. You're supposed to use template images so that the system can apply effects and show it properly in Dark mode. For a template image, the color is ignored. Only the alpha channel matters.
If you really want to defy Apple's recommendation, simply use a non-template image. Don't suffix your image name with "Template" and don't set the template property in code.
From the AppKit release notes for 10.10:
NSStatusItem appearance and Dark Menu support (Section added since WWDC seed)
There are a number of stylistic changes added and supported by
NSStatusItem, including appearance changes for Dark Menus. Template
images should always be used to ensure correct styling based on the
various states the status item can be in (light menu, dark menu,
inactive light, inactive dark, selected, disabled, etc).
NSStatusBarButton’s appearsDisabled property can be used to give the
image a disabled or “off” look without having the item be functionally
disabled. …

Disable NSVisualEffectView in Source List NSTableView

I have an older application that has a specific appearance based on NSCell-based NSTableView having Source List highlighting. Unfortunately, on Yosemite this adds the NSVisualEffectView vibrancy under the selected cell which breaks the appearance in an unpleasant way.
I can't find a way to opt-out of this behaviour, unfortunately.
Setting Regular highlighting breaks the appearance in another way (grey selection instead of blue).
Any idea if there is a way to opt-out of this behaviour on 10.10?
You need to change table view appearance from NSAppearanceNameVibrantLight to NSAppearanceNameAqua. If you're targeting OS X 10.8 or earlier try setting the appearance by editing XIB file directly:
<tableView appearanceType="aqua" ...>
Also make sure that table view background color is set to Default in IB.
I don't know if it works for your case, but the best way to disable an implicit visual effect view is to just embed your NSTable/OutlineView in another NSVisualEffectView and set that views state to inactive
visualEffectView.state = .inactive

NSScroller won't auto-hide and spawns a new NSTableColumn for himself

I can't figure out what's wrong with my NSScrollers.
Since an indefinite amount of time (I have been changing a lot of things in the source code of my App, but not on it's Xib design), my NSScrollers of all of my TableViews and OutlineView which are configured with "AutoHides" will not auto-hide at-all and will be spawned in a separate NSTableColumn.
I have no clue as where to look or how to debug this behavior, expect playing randomly with Interface Builder Settings for NSScrollViews .
I haven't made any weird categories that may interfere with the proper behavior of tableViews.
After hours of searching, I finally found a nice class that can do all I need by itself :RFOverlayScrollView. It's a nice subclass of NSScroller which is both transparent and auto-hidden; and published under the MIT License.
RFOverlayScrollView
RFOverlayScrollView is an NSScrollView subclass that shows its NSScroller in iOS style even when a mouse is attached.
Looks like you found what you want, but have you tried setting
[_scrollView setScrollerStyle:NSScrollerStyleOverlay];
This however hijacks the scrollbar setting, even if Show Scrollbars settings in System Preferences is set to Always.

Scrollable large NSDocument on Macbook Pro 13" XGA display

I'm having all kinds of trouble understanding how NSWindows can have larger documents than the window bounds in them.
Unfortunately, layout and contents prevents me from simply shrinking the document (and I wouldn't want to make the layout cramped for those with larger screens).
A school needs to run this app on their new 13", non-retina MacBook Pros. Scrolling is acceptable to them, but I'm unsure as to the approach, and I'd like your advice on the best way to handle this to avoid forced scrolling on larger screens.
I've tried setting the NSWindow min and max size and embedding the document in a Scroll View. But even though you can see part of the document view sticking out, no scroll bars appear (I have set them to Always in sys prefs).
If this is the way to go I would appreciate a link to a tutorial on this exact subject, because I'm a bit lost with all the measurements and options.
If not I'd like a pointer where to start and what to read. I'm experienced with Cocoa Touch but a relative newcomer to Mac development.
Without more information it sounds like you have embedded a NSScrollView but didn't set up the springs and struts properly to allow the scroll view to resize when its parent view (assuming it's the window) resizes.
You might want to check out Specifying a View’s Behavior as Its Container Resizes in the Interface Builder Help documentation.

Resources