I have a NSScrollView, which was set to:
MyNSScrollView.hasHorizontalScroller = YES;
MyNSScrollView.hasVerticalScroller = YES;
MyNSScrollView.autohidesScrollers = YES;
MyNSScrollView.scrollerStyle = NSScrollerStyleOverlay;
I noticed that when if there's no trackpad connecting to OS X, and by default, the NSScrollView
will ignore my settings in the code and force the scrollers always shown:
I can only either change my system settings to "When scrolling" or set hasHorizontalScroller
etc. to NO
to hide it, and the later will disable mouse scrolling which is not the result I want.
By default (Automatically based on mouse or trackpad) will always display the scroller if the user has no trackpad, even when the content size does not exceed the frame size. But if you have a trackpad, it will be overlay style that no matter the scroller shows or not, it's above the content.
The difference between the 2 is that "legacy" style will take up spaces in the scrollerview. It'd be a problem if you were relaying on the visiableRect
value for calculation, or your contents needs to remain certain aspect-ratio via constraints.
Is there a way to force hide them without disabling them?
hasHorizontalScroller
andhasVerticalScroller
toNO
. – Maugre