From cdfd1ae57a370544a05ee9736c3bfd8ea7060b1f Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sat, 9 Jan 2021 21:45:16 +0000 Subject: [PATCH] TUpDown: use the MouseEnter/MouseLeave methods to fire the OnMouseEnter and OnMouseLeave events. Slightly alters r64151 #6a41fe9801. git-svn-id: trunk@64369 - --- lcl/comctrls.pp | 4 ++-- lcl/include/customupdown.inc | 38 +++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index 19f26b2c76..d138c66011 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -1904,8 +1904,8 @@ type FThousands: Boolean; FWrap: Boolean; FUseWS: Boolean; - procedure CheckMouseEntering; - procedure CheckMouseLeaving; + function CheckMouseEntering: Boolean; + function CheckMouseLeaving: Boolean; function GetPosition: SmallInt; procedure BTimerExec(Sender : TObject); function GetFlat: Boolean; diff --git a/lcl/include/customupdown.inc b/lcl/include/customupdown.inc index 033074d38b..aff7670d79 100644 --- a/lcl/include/customupdown.inc +++ b/lcl/include/customupdown.inc @@ -53,14 +53,14 @@ end; procedure TUpDownButton.MouseEnter; begin - FUpDown.CheckMouseEntering; - inherited MouseEnter; + inherited MouseEnter; //does UpdateState o.a., so call this as well + FUpDown.MouseEnter; end; procedure TUpDownButton.MouseLeave; begin - FUpDown.CheckMouseLeaving; - inherited MouseLeave; + inherited MouseLeave; //does UpdateState o.a., so call this as well + FUpDown.MouseLeave; end; procedure TUpDownButton.MouseDown(Button: TMouseButton; Shift: TShiftState; @@ -539,11 +539,21 @@ begin end; procedure TCustomUpDown.MouseEnter; -begin // This should never happen because buttons cover the whole component. +begin + if CheckMouseEntering then + begin + inherited MouseEnter; + FMouseInsideComp := True; + end; end; procedure TCustomUpDown.MouseLeave; -begin // This should never happen because buttons cover the whole component. +begin + if CheckMouseLeaving then + begin + inherited MouseLeave; + FMouseInsideComp := False; + end; end; procedure TCustomUpDown.DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); @@ -592,26 +602,22 @@ begin SetAssociate(nil); end; -procedure TCustomUpDown.CheckMouseEntering; +function TCustomUpDown.CheckMouseEntering: Boolean; // Mouse in entering this control. begin - if FMouseInsideComp then Exit; // Already inside, moving between 2 buttons. - inherited MouseEnter; - FMouseInsideComp := True; + //debugln(['TCustomUpDown.CheckMouseEntering: FMouseInsideComp=',FMouseInsideComp]); + Result := not FMouseInsideComp; end; -procedure TCustomUpDown.CheckMouseLeaving; +function TCustomUpDown.CheckMouseLeaving: Boolean; // Mouse in leaving this control. var P: TPoint; begin GetCursorPos(P); P:=ScreenToClient(P); - if PtInRect(ClientRect, P) then - exit; // Still inside, moving between 2 buttons. - Assert(FMouseInsideComp, 'TCustomUpDown.DecMouseEnterLeaveCnt: FMouseInsideComp=False'); - FMouseInsideComp := False; - inherited MouseLeave; + Result := not PtInRect(ClientRect, P); + //debugln(['TCustomUpDown.CheckMouseLeaving: PtInRect(ClientRect, P)=',PtInRect(ClientRect, P)]); end; function TCustomUpDown.GetPosition: SmallInt;