Lupurus
Lupurus

Reputation: 4209

NSScrollView Overlay Mavericks

since Mavericks I have the following problem in my app: I programmatically create a NSBox with the size of the window. Then I add it as a subview to the windows contentView. So I want to overlay all interface elements on the view. This worked perfectly since Mountain Lion, in Mavericks the NSScrollView will not get overlayed.

Maybe you can see it in a similar example from apple. https://developer.apple.com/library/mac/samplecode/OverlayView/Introduction/Intro.html

Any hints for a workaround? This seems to be a bug, but I have no Apple Dev Account to file a bug.

Upvotes: 3

Views: 554

Answers (3)

Radu Simionescu
Radu Simionescu

Reputation: 4695

afaik, overlaying sibling views is supported only for layer backed views. Non layer backed views which overlay each other are not recommended. For some osx version, such situations were not guaranteed to draw properly. Your best long term solution here is to make your overlay view, a layer backed view

Upvotes: 2

Chris Mason
Chris Mason

Reputation: 79

I think a better solution would be to implement

- (BOOL)wantsLayer

and return NO.

Apple has apparently changed NSScrollView in 10.9 so it draws in layers -- for special scrolling effects, or speed, or maybe just to give us something to do, because we're all so under-worked. This affects NSTextViews, NSTableViews, and PDFViews among others. I have seen lots of cases (for example, my app's main document view) where this is fine, but in several circumstances it messes up horribly. Two examples: a resizing Preferences panel that animates fade in/fade out when you change panes, and a detail view with sections that can collapse. In the latter case, if you click on a table view in 10.9 the table view VANISHES, then if you open a collapsed section it reappears UPSIDE DOWN.

By refusing to use layers as mentioned above, you're declining to participate in this madness and forcing the scroll view to draw the old way.

Upvotes: 2

Lupurus
Lupurus

Reputation: 4209

Haha, found the solution by coincidence (I still even don't know, why it's working ^^). I created a subclass of NSScrollView and added this:

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
    return;
}

Upvotes: -1

Related Questions