From aaf4d4d12fe633a7a549f16702b0fd8db164bd8a Mon Sep 17 00:00:00 2001 From: dmitry Date: Sun, 23 Feb 2020 04:04:39 +0000 Subject: [PATCH] cocoa: passing scroll part information, whenever the scroll part is known git-svn-id: trunk@62663 - --- lcl/interfaces/cocoa/cocoaprivate.pas | 2 +- lcl/interfaces/cocoa/cocoascrollers.pas | 19 +++---------------- lcl/interfaces/cocoa/cocoawscommon.pas | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoaprivate.pas b/lcl/interfaces/cocoa/cocoaprivate.pas index 0b382fee13..a5380764e5 100644 --- a/lcl/interfaces/cocoa/cocoaprivate.pas +++ b/lcl/interfaces/cocoa/cocoaprivate.pas @@ -91,7 +91,7 @@ type procedure DidResignKeyNotification; procedure SendOnChange; procedure SendOnTextChanged; - procedure scroll(isVert: Boolean; Pos: Integer); + procedure scroll(isVert: Boolean; Pos: Integer; AScrollPart: NSScrollerPart = NSScrollerNoPart); // non event methods function DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; function GetPropStorage: TStringList; diff --git a/lcl/interfaces/cocoa/cocoascrollers.pas b/lcl/interfaces/cocoa/cocoascrollers.pas index e327e5cd54..83dbcd3a93 100644 --- a/lcl/interfaces/cocoa/cocoascrollers.pas +++ b/lcl/interfaces/cocoa/cocoascrollers.pas @@ -180,29 +180,16 @@ var sz : Integer; dlt : double; v : double; -//const - //WinPageOfs : integer = 64; // this is an "ofset" of the pageInc used in Windows - // so the click on "large" makes two pages overlap begin Result := false; case prt of NSScrollerDecrementPage: begin adj := -sc.largeInc; - if adj = 0 then - begin - adj := -sc.pageInt; - //if (sc.PageInt>WinPageOfs) then - // inc(adj, WinPageOfs); - end; + if adj = 0 then adj := -sc.pageInt; end; NSScrollerIncrementPage: begin adj := sc.largeInc; - if adj = 0 then - begin - adj := sc.pageInt; - //if (sc.PageInt>WinPageOfs) then - // dec(adj, WinPageOfs); - end; + if adj = 0 then adj := sc.pageInt; end; NSScrollerDecrementLine: begin adj := -sc.smallInc; @@ -843,7 +830,7 @@ begin HandleMouseDown(self, locInWin, prt); if Assigned(callback) then - callback.scroll( not IsHorizontal(), lclPos); + callback.scroll(not IsHorizontal(), lclPos, prt); end; function TCocoaScrollBar.IsHorizontal: Boolean; diff --git a/lcl/interfaces/cocoa/cocoawscommon.pas b/lcl/interfaces/cocoa/cocoawscommon.pas index 40f19f3ae4..9d369ff901 100644 --- a/lcl/interfaces/cocoa/cocoawscommon.pas +++ b/lcl/interfaces/cocoa/cocoawscommon.pas @@ -92,7 +92,7 @@ type procedure DidResignKeyNotification; virtual; procedure SendOnChange; virtual; procedure SendOnTextChanged; virtual; // text controls (like spin) respond to OnChange for this event, but not for SendOnChange - procedure scroll(isVert: Boolean; Pos: Integer); virtual; + procedure scroll(isVert: Boolean; Pos: Integer; AScrollPart: NSScrollerPart); virtual; function DeliverMessage(var Msg): LRESULT; virtual; overload; function DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; virtual; overload; procedure Draw(ControlContext: NSGraphicsContext; const bounds, dirty: NSRect); virtual; @@ -1329,10 +1329,12 @@ begin SendSimpleMessage(Target, CM_TEXTCHANGED); end; -procedure TLCLCommonCallback.scroll(isVert: Boolean; Pos: Integer); +procedure TLCLCommonCallback.scroll(isVert: Boolean; Pos: Integer; + AScrollPart: NSScrollerPart); var LMScroll: TLMScroll; b: Boolean; + lclCode: Integer; begin FillChar(LMScroll{%H-}, SizeOf(LMScroll), #0); //todo: this should be a part of a parameter @@ -1344,7 +1346,15 @@ begin LMScroll.Msg := LM_HSCROLL; LMScroll.Pos := Pos; - LMScroll.ScrollCode := SB_THUMBPOSITION; //SIF_POS; + case AScrollPart of + NSScrollerDecrementPage: lclCode := SB_PAGELEFT; + NSScrollerIncrementPage: lclCode := SB_PAGERIGHT; + NSScrollerDecrementLine: lclCode := SB_LINELEFT; + NSScrollerIncrementLine: lclCode := SB_LINERIGHT; + else + lclCode := SB_THUMBPOSITION; + end; + LMScroll.ScrollCode := lclCode; //SIF_POS; LCLMessageGlue.DeliverMessage(Target, LMScroll); end;