From ab4727c1013e1b39f4071e4918f871ae025a769d Mon Sep 17 00:00:00 2001 From: rich2014 Date: Sun, 11 Feb 2024 21:09:49 +0800 Subject: [PATCH] Cocoa: Fix Document size in TCocoaScrollView in the previous implementation, the entire frame of ScrollView was mistakenly used instead of Client Bound. --- lcl/interfaces/cocoa/cocoawinapi.inc | 2 +- lcl/interfaces/cocoa/cocoawsforms.pas | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index cf0f47c4a7..4f80a55f74 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -1718,7 +1718,7 @@ begin begin sc:=TCocoaScrollView(obj); if sc.isCustomRange and (ScrollInfo.fMask and SIF_RANGE>0) then begin - f:=sc.frame.size; + f:=sc.contentSize; sz:=NSView(sc.documentView).frame.size; // type casting is here for the compiler. for i386 it messes up types flg:=sc.documentView.autoresizingMask; diff --git a/lcl/interfaces/cocoa/cocoawsforms.pas b/lcl/interfaces/cocoa/cocoawsforms.pas index 0227a386cd..2e1023989d 100644 --- a/lcl/interfaces/cocoa/cocoawsforms.pas +++ b/lcl/interfaces/cocoa/cocoawsforms.pas @@ -535,21 +535,25 @@ var docview: TCocoaCustomControl; lcl : TLCLCommonCallback; begin - docview := TCocoaCustomControl.alloc.lclInitWithCreateParams(AParams); - scrollcon:=EmbedInScrollView(docView); + scrollcon:= TCocoaScrollView.alloc.lclInitWithCreateParams(AParams); + ScrollViewSetBorderStyle(scrollcon, TScrollingWinControl(AWincontrol).BorderStyle); + scrollcon.setDrawsBackground(false); // everything is covered anyway scrollcon.setBackgroundColor(NSColor.windowBackgroundColor); scrollcon.setAutohidesScrollers(True); scrollcon.setHasHorizontalScroller(True); scrollcon.setHasVerticalScroller(True); scrollcon.isCustomRange := true; + docview:= TCocoaCustomControl.alloc.init; + docview.setFrameSize( scrollcon.contentSize ); + scrollcon.setDocumentView(docview); + lcl := TLCLCommonCallback.Create(docview, AWinControl, scrollcon); lcl.BlockCocoaUpDown := true; + scrollcon.callback := lcl; docview.callback := lcl; docview.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable); - scrollcon.callback := lcl; - scrollcon.setDocumentView(docview); - ScrollViewSetBorderStyle(scrollcon, TScrollingWinControl(AWincontrol).BorderStyle); + Result := TLCLHandle(scrollcon); end;