EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inserting Text via drag&drop

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
jfudickar



Joined: 12 Jun 2006
Posts: 38
Location: Eschborn, Germany

PostPosted: Tue Oct 17, 2006 9:32 pm    Post subject: Inserting Text via drag&drop Reply with quote

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
View user's profile Send private message Visit poster's website
jfudickar



Joined: 12 Jun 2006
Posts: 38
Location: Eschborn, Germany

PostPosted: Tue Oct 17, 2006 9:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Mon Oct 23, 2006 1:41 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
jfudickar



Joined: 12 Jun 2006
Posts: 38
Location: Eschborn, Germany

PostPosted: Tue Oct 24, 2006 8:35 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Tue Oct 24, 2006 8:52 am    Post subject: Reply with quote

Yes, give additional comments.

Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group