From e171cf6f33e5789501f7efc6aef34575062f8ead Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Wed, 2 Nov 2022 21:59:00 +0100 Subject: [PATCH] TAChart: Workaround for TChartListbox not detecting clicks on checkbox and series icon correctly on macOS Monterey. See https://forum.lazarus.freepascal.org/index.php/topic,61074.msg458489.html. --- components/tachart/tachartlistbox.pas | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/tachart/tachartlistbox.pas b/components/tachart/tachartlistbox.pas index 0727168fae..3fcef9a730 100644 --- a/components/tachart/tachartlistbox.pas +++ b/components/tachart/tachartlistbox.pas @@ -549,7 +549,7 @@ end; procedure TChartListbox.MouseDown( AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer); var - rcb, ricon: TRect; + R, rcb, ricon: TRect; index: Integer; p: TPoint; begin @@ -560,7 +560,17 @@ begin p := Point(AX, AY); index := GetIndexAtXY(AX, AY); if index < 0 then exit; - CalcRects(ItemRect(index), rcb, ricon); + R := ItemRect(index); + {$IFDEF DARWIN} + { Workaround for ItemRect returning something different than what is + passed to DrawItem in macOS Monterey. + See discussion in https://forum.lazarus.freepascal.org/index.php/topic,61074.0.html + The consequence of this workaround is that there can only be a single + column, but Columns > 1 does not work on cocoa anyway. } + R.Left := 0; + R.Right := ClientWidth; + {$ENDIF} + CalcRects(R, rcb, ricon); if (cloShowCheckboxes in Options) and IsPointInRect(p, rcb) then ClickedCheckbox(index) else if (cloShowIcons in Options) and IsPointInRect(p, ricon) then