Cocoa: Fix Document size in TCocoaScrollView

in the previous implementation, the entire frame of ScrollView was mistakenly used instead of Client Bound.
This commit is contained in:
rich2014 2024-02-11 21:09:49 +08:00
parent c00f60ad39
commit ab4727c101
2 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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;