[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.

Malcolm

==================================

procedure TForm1.UpButtonClick ( Sender: TObject ) ;
var
   newcaretPos: Integer;
   x: Integer;
begin
   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]) + 
Length(LineEnding);
   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;
   Memo1.SetFocus;
end;







More information about the Lazarus mailing list