[Lazarus] Memo for touchscreen

Malcolm Poole malcolm at lingua-z.co.uk
Fri Jul 19 16:21:53 CEST 2013

On 19/07/13 13:45, Koenraad Lelong wrote:
> Works fine, except for navigating up and down. Left and right is OK, I
> have to find out how to know on what line the cursor is, and then going
> to the next/previous line, if possible.

Well I did say it was only to get you started :D

Memo1.CursorPos.y will tell you on which line the cursor is.

Here's a suggestion for navigating to the line above. I'll leave it to 
you to work out how to navigate to the line below.



procedure TForm1.UpButtonClick ( Sender: TObject ) ;
   newcaretPos: Integer;
   x: Integer;
   newcaretPos := 0;
   writeln(Memo1.CaretPos.Y, #32, Memo1.CaretPos.X);
   for x := 0 to Memo1.CaretPos.Y-2 do
     newcaretPos := newcaretPos + Length(Memo1.Lines[x]) + 
   if Length(Memo1.Lines[Memo1.CaretPos.Y-1]) < Memo1.CaretPos.X
      then newcaretPos := newcaretPos + 
Length(Memo1.Lines[Memo1.CaretPos.Y-1]) + 1
      else newcaretPos := newcaretpos + Memo1.CaretPos.X;
   Memo1.SelStart := newcaretPos;

More information about the Lazarus mailing list