Insert text at cursor position
-
- Posts: 5
- Joined: Thu Oct 26, 2006 8:28 am
Insert text at cursor position
I need to paste some text at cursor position and the cursor should be placed at the end of the placed text. Please explain how i can do it?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 5
- Joined: Thu Oct 26, 2006 8:28 am
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
InsertText moves caret to the end of the inserted text (or to the beginning, depending on the last (optional) parameter.
May be you call Format after InsertText? It's not needed, and moves caret to the beginning.
Caret is moved by SetSelectionBounds method (set the both bounds to the same values to move caret without making selection)
May be you call Format after InsertText? It's not needed, and moves caret to the beginning.
Caret is moved by SetSelectionBounds method (set the both bounds to the same values to move caret without making selection)
procedure TForm1.Button1Click(Sender: TObject);
//var remember: string; ---> PRIVATE
begin
(*
a)
clipboard.clear;
if Memo.SelectionExists=false then memo.selectCurrentLine;
memo.CopyDef;
Memo.Deselect;
*)
// b)
remember:= 'Hello Paul';
end;
procedure TForm1.Button2Click(Sender: TObject);
// only for b)
var s, leer, strich: string;
itemNo, offs: integer;
//end of only for b)
begin
(*
a)
memo.SetFocus;
Memo.paste;
*)
// b)
memo.setfocus;
//ItemNo := memo.ItemCount-1; Offs := memo.GetOffsAfterItem(ItemNo);
//memo.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs); //at the end of memo
Memo.insertText(remember,false);
end;
//var remember: string; ---> PRIVATE
begin
(*
a)
clipboard.clear;
if Memo.SelectionExists=false then memo.selectCurrentLine;
memo.CopyDef;
Memo.Deselect;
*)
// b)
remember:= 'Hello Paul';
end;
procedure TForm1.Button2Click(Sender: TObject);
// only for b)
var s, leer, strich: string;
itemNo, offs: integer;
//end of only for b)
begin
(*
a)
memo.SetFocus;
Memo.paste;
*)
// b)
memo.setfocus;
//ItemNo := memo.ItemCount-1; Offs := memo.GetOffsAfterItem(ItemNo);
//memo.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs); //at the end of memo
Memo.insertText(remember,false);
end;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: