On 16/08/06, Adrian Maier <[EMAIL PROTECTED]> wrote:
I am writing a small html editor ; the purpose is to translate html pages in an
easy way. I have two TSynEdit controls : one is read-only and displays the
original file , and the 2nd is editable and is used to write the
translated text.
I wish to synchronise the two TSynEdits: when i move up and down in the
editable SynEdit2, i'd like to make sure that the corresponding line is
visible in SynEdit1.
So, the question is which event could i use to detect when the user moves
the cursor (caret) to another line ?
I've found a solution. It might not be the best one, but it does what i want:
everytime i press a key in SynEdit2, it highlights the corresponding line in
the other SynEdit1.
procedure TFrmMain.SynEdit2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
l1,l2:integer;
begin
l1:=SynEdit1.CaretY;
l2:=SynEdit2.CaretY;
if l1<>l2 then begin
SynEdit1.SelEnd:=SynEdit1.SelStart;
SynEdit1.CaretY:=l2;
SynEdit1.SelectLine;
end;
end;
I am very impressed to see how easy it was to write this small editor (in about
one day), considering how little experience i have with Lazarus.
Best wishes,
Adrian Maier
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives