Cocoa: Integrate not Managed ScrollBar and Legacy Implement

This commit is contained in:
rich2014 2024-06-28 00:35:45 +08:00
parent 79b3c78ac0
commit 71d3a8aebb
2 changed files with 16 additions and 17 deletions

View File

@ -208,6 +208,8 @@ type
procedure setFrame(newValue: NSRect); override; procedure setFrame(newValue: NSRect); override;
end; end;
function createLegacyScroller: TCocoaScrollBar;
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean; function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
// These settings are set by a user in "System Preferences" // These settings are set by a user in "System Preferences"
@ -441,23 +443,15 @@ begin
end; end;
end; end;
procedure allocScroller(parent: TCocoaManualScrollView; var sc: NSScroller; dst: NSRect; aVisible: Boolean); // for the Scroller created separately through TCocoaWSScrollBar.CreateHandle(),
// due to the lack of the control over the Layout by TCocoaManualScrollView,
// only the Legacy Style can be used for compatibility.
// it's the same logical relationship as NSScrollView and NSScroller.
function createLegacyScroller: TCocoaScrollBar;
begin begin
sc:=TCocoaScrollBar(TCocoaScrollBar.alloc).initWithFrame(dst); Result:= TCocoaScrollBar(TCocoaScrollBar.alloc);
parent.addSubview(sc); Result.manager:= TCocoaScrollStyleManagerLegacy.createForScrollBar;
{$ifdef BOOLFIX} Result.effect:= Result.manager.createScrollBarEffect(Result);
sc.setEnabled_(Ord(true));
sc.setHidden_(Ord(not AVisible));
{$else}
sc.setEnabled(true);
sc.setHidden(not AVisible);
{$endif}
TCocoaScrollBar(sc).preventBlock := true;
//Suppress scrollers notifications.
TCocoaScrollBar(sc).callback := parent.callback;
TCocoaScrollBar(sc).suppressLCLMouse := true;
sc.setTarget(sc);
sc.setAction(objcselector('actionScrolling:'));
end; end;
function allocScroller(parent: TCocoaManualScrollView; dst: NSRect; aVisible: Boolean) function allocScroller(parent: TCocoaManualScrollView; dst: NSRect; aVisible: Boolean)

View File

@ -2270,7 +2270,12 @@ begin
prm.Height:=ScrollBase; prm.Height:=ScrollBase;
end; end;
scr:=NSView(TCocoaScrollBar.alloc).lclInitWithCreateParams(prm); // for the Scroller created separately through TCocoaWSScrollBar.CreateHandle(),
// due to the lack of the control over the Layout by TCocoaManualScrollView,
// only the Legacy Style can be used for compatibility.
// it's the same logical relationship as NSScrollView and NSScroller.
scr:= createLegacyScroller;
scr.lclInitWithCreateParams(prm);
scr.callback:=TLCLCommonCallback.Create(scr, AWinControl); scr.callback:=TLCLCommonCallback.Create(scr, AWinControl);
// OnChange (scrolling) event handling // OnChange (scrolling) event handling