From 37a05f796d8bb636873e411f24f94d8f37f4c51e Mon Sep 17 00:00:00 2001 From: Petko Georgiev Date: Tue, 20 Apr 2021 14:50:28 +1000 Subject: Bug [#2248]. Make autocompletion look the same on macOS 11 as macOS 10 by using NSTableViewStylePlain. This prevents truncation of the text of items as well as avoiding problems with size and padding. --- cocoa/PlatCocoa.mm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 7f26f4bb0..50e42f38e 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1986,6 +1986,11 @@ void ListBoxImpl::Create(Window & /*parent*/, int /*ctrlID*/, Scintilla::Point p table.target = ds; table.doubleAction = @selector(doubleClick:); table.selectionHighlightStyle = NSTableViewSelectionHighlightStyleSourceList; + + if (@available(macOS 11.0, *)) { + [table setStyle: NSTableViewStylePlain]; + } + wid = (__bridge_retained WindowID)winLB; } @@ -2016,8 +2021,13 @@ PRectangle ListBoxImpl::GetDesiredRect() { PRectangle rcDesired; rcDesired = GetPosition(); - // There appears to be an extra pixel above and below the row contents - CGFloat itemHeight = table.rowHeight + 2; + CGFloat itemHeight; + if (@available(macOS 11.0, *)) { + itemHeight = table.rowHeight; + } else { + // There appears to be an extra pixel above and below the row contents + itemHeight = table.rowHeight + 2; + } int rows = Length(); if ((rows == 0) || (rows > desiredVisibleRows)) @@ -2027,13 +2037,6 @@ PRectangle ListBoxImpl::GetDesiredRect() { rcDesired.right = rcDesired.left + maxItemWidth + aveCharWidth; rcDesired.right += 4; // Ensures no truncation of text - if (@available(macOS 11, *)) { - // macOS 11 requires some extra space possibly due to the rounded highlight. - // There may be a better way to discover how much space is required - // but an extra 22 pixels fixes it for almost all tested cases. - rcDesired.right += 22; - } - if (Length() > rows) { [scroller setHasVerticalScroller: YES]; rcDesired.right += [NSScroller scrollerWidthForControlSize: NSControlSizeRegular -- cgit v1.2.3