View previous topic :: View next topic |
Author |
Message |
jfudickar
Joined: 12 Jun 2006 Posts: 38 Location: Eschborn, Germany
|
Posted: Tue Oct 17, 2006 9:32 pm Post subject: Inserting Text via drag&drop |
|
|
Hi Michael,
i use the following code
Code: |
procedure InsertStringsIntoEditor(Sender: TCustomSyntaxMemo; NewString: string;
x: Integer = -1; y: Integer = -1; CursorPos: Integer = 0);
var
s: TStrings;
i, j: Integer;
Pt: TPoint;
begin
if not assigned(Sender) then
Exit;
s := TStringList.Create;
try
Sender.BeginUpdate;
S.Text := NewString;
if (x >= 0) and (y >= 0) then
pt := Sender.MouseToCaret(x, y)
else
Pt := Sender.CaretPos;
Sender.ExecCommand(smGotoxy, @pt);
//Sender.InsertText(NewString);
Sender.InsertTextBlock( s, Pt);
finally
FreeAndNil(s);
Sender.EndUpdate;
end;
end; |
to insert text via drag&drop.
This seems to work fine. But when i drop the code some lines behind the last line it's allways added to the last line and not to the position where i have dropped the text.
Any ideas/suggestions?
Greetings
Jens |
|
Back to top |
|
|
jfudickar
Joined: 12 Jun 2006 Posts: 38 Location: Eschborn, Germany
|
Posted: Tue Oct 17, 2006 9:37 pm Post subject: |
|
|
Second question:
if i use
Code: | Sender.InsertText(NewString); |
instead of
Code: | Sender.InsertTextBlock( s, Pt); |
is it possible that the code is inserted like manually entering it.
Description :
I think it's the smarttab option.
I start at column 5 and enter some words, then i press return. The cursor again is at column 5.
This something i want to simulate via drag&drop. The problem with InsertTextBlock is that the text allways begins at column 5, but that the text is written into the following lines, and not that the lines are inserted and each line starts at column 5.
Do you understand what i mean?
Greetings
Jens |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Mon Oct 23, 2006 1:41 pm Post subject: |
|
|
Hi Jens,
1. Caret can not be set to line after text, i.e. caret may be placed only in existent line. It will be better to add this question to Mantis, because it requires new functionality in the control.
2. During InsertText there is no indentation of multiline text. Autoindent is also available during keyboard input. for inserting multi line text you may use next code:
Code: | SL := TStringList.Create;
try
SL.Text := S;
for i := 0 to SL.Count - 1 do
begin
InsertText(SL[i]);
if i < SL.Count - 1 then
ExecCommand(smLineBreak);
end;
finally
SL.Free;
end; |
Michael. |
|
Back to top |
|
|
jfudickar
Joined: 12 Jun 2006 Posts: 38 Location: Eschborn, Germany
|
Posted: Tue Oct 24, 2006 8:35 am Post subject: |
|
|
Hi Michael,
i think a workaround for question one could be to call ExecCommand(smLineBreak); so long until the CurrentLine is behind the wished position.
Comments?
Greetings and thanks
Jens |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Tue Oct 24, 2006 8:52 am Post subject: |
|
|
Yes, give additional comments.
Michael. |
|
Back to top |
|
|
|