If you click the mouse outside the text on the right (white space), ACursorPos variable will remain in its value from another line
The solution is to verify the search of result .If the mouse click is far from the text .The full length of the text will be taken
procedure TfpgMemo.CursorPosFromXY
....
+ inText:Boolean =false;
begin
...
if abs(cx - x) < abs(cpx - x) then
begin
cpx := cx;
cp := n;
+ inText:=true;
end;
end;
...
+ if inText then ACursorPos := cp
+ else
+ ACursorPos:=UTF8Length(ls);
end;
If you click the mouse outside the text on the right (white space), ACursorPos variable will remain in its value from another line
The solution is to verify the search of result .If the mouse click is far from the text .The full length of the text will be taken