我認爲您可以通過將兩個事件分配給您的編輯器來實現您的目標:DragOver/DragDrop。
1 /你測試在DragOver事件的有效性,也通過調用GetPositionOfMouse
Procedure TForm1.EditorDragOver(Sender,Source: TObject;X,Y: Integer; State: TDragState; Var Accept: Boolean);
Var
LCoord: TBufferCoord;
LMemo: TSynMemo;
Begin
LMemo := TSynMemo(Sender);
// In your case you would rather test something with your tree...
Accept := Clipboard.AsText <> '';
// "As you drag over the TSynEdit, the caret should mark the current drop position": OK
If LMemo.GetPositionOfMouse(LCoord) Then
LMemo.CaretXY := LCoord;
End;
2 /你用在DragDrop事件編輯命令,以清除移動插入符號選擇和插入字符
Procedure TForm1.EditorDragDrop(Sender, Source: TObject; X,Y: Integer);
Var
LMemo: TSynMemo;
Begin
LMemo := TSynMemo(Sender);
// "When the text is dropped, it should replace any text that is currently highlighted." : OK
If LMemo.SelAvail Then
LMemo.ExecuteCommand(ecDeleteChar , #0, Nil);
// Paste, same comment as previously, here it's just an example...
LMemo.ExecuteCommand(ecPaste, #0, Nil);
End;
這將不得不根據您的上下文進行調整。