From 35b41f5b08bc0fb10db7376761350fa51bfa3e58 Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Sun, 26 Nov 2023 20:51:04 -0800 Subject: [PATCH] Honor the NSScroller.Style.overlay scrollbar style This makes sure that, after the recent UI overhaul (PR #385, #383), we now honor the "Scroll bar behavior" settings in System Preferences > Appearance. This also fixes the problem with the .legacy style: that the scroll bar is always visible and always gets in the highlighted item. --- .../CandidateUI/VerticalCandidateController.swift | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Packages/CandidateUI/Sources/CandidateUI/VerticalCandidateController.swift b/Packages/CandidateUI/Sources/CandidateUI/VerticalCandidateController.swift index b9305bd6..88e03311 100644 --- a/Packages/CandidateUI/Sources/CandidateUI/VerticalCandidateController.swift +++ b/Packages/CandidateUI/Sources/CandidateUI/VerticalCandidateController.swift @@ -327,13 +327,6 @@ extension VerticalCandidateController: NSTableViewDataSource, NSTableViewDelegat } keyLabelStripView.setNeedsDisplay(keyLabelStripView.frame) - - // fix a subtle OS X "bug" that, since we force the scroller to appear, - // scrolling sometimes shows a temporarily "broken" scroll bar - // (but quickly disappears) - if scrollView.hasVerticalScroller { - scrollView.verticalScroller?.setNeedsDisplay() - } } } @@ -450,8 +443,10 @@ extension VerticalCandidateController: NSTableViewDataSource, NSTableViewDelegat scrollView.hasVerticalScroller = true let verticalScroller = scrollView.verticalScroller verticalScroller?.controlSize = controlSize - verticalScroller?.scrollerStyle = .legacy - scrollerWidth = NSScroller.scrollerWidth(for: controlSize, scrollerStyle: .legacy) + verticalScroller?.scrollerStyle = NSScroller.preferredScrollerStyle + if NSScroller.preferredScrollerStyle == .legacy { + scrollerWidth = NSScroller.scrollerWidth(for: controlSize, scrollerStyle: NSScroller.preferredScrollerStyle) + } } keyLabelStripView.keyLabelFont = keyLabelFont