From 2094de32dcec832b50b3937ab7ae0cba441557fc Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 24 Sep 2016 00:06:01 +0000 Subject: [PATCH] SynEdit: fix pixel to char, outside textarea git-svn-id: trunk@53023 - --- components/synedit/lazsyntextarea.pp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/synedit/lazsyntextarea.pp b/components/synedit/lazsyntextarea.pp index be908f3267..6c367b7813 100644 --- a/components/synedit/lazsyntextarea.pp +++ b/components/synedit/lazsyntextarea.pp @@ -1206,10 +1206,14 @@ function TLazSynTextArea.PixelsToRowColumn(Pixels: TPoint; aFlags: TSynCoordinateMappingFlags): TPoint; begin // Inludes LeftChar, but not Topline - if not (scmForceLeftSidePos in aFlags) then - Pixels.X := Pixels.X + (CharWidth div 2); // nearest side of char - Result.X := (Pixels.X - FTextBounds.Left) div CharWidth - + LeftChar; + if (Pixels.X >= FTextBounds.Left) and (Pixels.X < FTextBounds.Right) then begin + if not (scmForceLeftSidePos in aFlags) then + Pixels.X := Pixels.X + (CharWidth div 2); // nearest side of char + Result.X := (Pixels.X - FTextBounds.Left) div CharWidth + + LeftChar; + end + else + Result.X := 0; Result.Y := (Pixels.Y - FTextBounds.Top) div LineHeight; if (not(scmIncludePartVisible in aFlags)) and (Result.Y >= LinesInWindow) then begin