[ Shrink NSScroller of NSScrollView in layer-backed view ]
I'm experiencing a weird problem (Bug?): Say I have a
WebView, which will scroll vertically.
I now want to shrink the
mainFrame's vertical scroller a little bit, so that its height is smaller than the
The reason for this is that I want to pin two views (on top and on bottom edge) above the webview.
I did that easily in the frameLoad delegate method by altering the verticalScroller's frame (altering origin and height).
It works, but:
However once I set the webView and it's parent NSView to be layer-backed, it stops working, the scroller resets itself to the default position and height.
Now I don't know if this is a bug or not. Is there any other way I could try to 'inset' the scroller?
Have you tried subclassing NSScroller, setting it as the vertical scroller for your NSScrollView and overriding
-(void) setFrameOrigin:(NSPoint)origin; -(void) setFrameSize:(NSSize)size;
I assume making the NSView layer-backed causes frameSize to be set again(NSScrollView seems to take quite a bit of control on this because when you create a custom scroller, there is no "clean" way to set an NSScroller as horizontal or vertical other than calling -initWithFrame: with
- height > width to automatically set it as vertical
- width > height to automatically set it as horizontal
My other suggestion would be, if you want the NSScroller to not fully reflect the size of its parent NSScrollView would you be better off having an NSView as the content view of the webview. And the NSView have 3 subviews. Two views at the top and bottom pinned, and one NSScrollView in the middle. No custom NSScroller necessary in this case.