Lazarus

Programming => Packages and Libraries => RichMemo => Topic started by: bungayst on August 12, 2022, 04:07:23 pm

Title: Drag & drop into RichMemo
Post by: bungayst on August 12, 2022, 04:07:23 pm
I want to be able to Drag text into a RichMemo. The drag and drop is easy, inserting the text at the location under the mouse cursor is the difficult bit. Anyone done this?
Title: Re: Drag & drop into RichMemo
Post by: bungayst on August 24, 2022, 04:38:36 pm
[SOLVED] Thanks for all the help.

CaretPos has nothing to do with it, which is misleading.

To drag and drop text from a TreeView node into a RichMemo;

procedure TForm1.RichMemo1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
  iNode  : String;

begin
  inode := TTreeview(Source).Selected.Text; //Treeview is the Source.

  RichMemo1.SelStart:=RichMemo1.CharAtPos(X,Y);
  RichMemo1.SelText:=iNode;

end;

TinyPortal © 2005-2018