Inserting a code snippet by drag and drop

SyntaxEditor for WPF Forum

Posted 4 years ago by Daisuke Nakada
Version: 17.2.0665


I'm now implementing drag and drop function on my syntax editor.

Is it possible to insert a code snippet when something is droped?


I would like to know the best way to do this and how to get the offset where the drop action happens.

I'm using SyntaxEditor.PasteDragDrop to detect a drag and drop action.


Thank you.

Comments (2)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA


I don't believe we pass that offset in our event args, but you could get it with this logic, which is effectively what we do:

Point location = view.TransformToTextArea(e.DragEventArgs.GetPosition(view.VisualElement));
TextPosition dropPosition = view.LocationToPosition(location, LocationToPositionAlgorithm.BestFit);
int dropOffset = view.CurrentSnapshot.PositionToOffset(dropPosition);

Actipro Software Support

Posted 4 years ago by Daisuke Nakada

Thank you for telling me that technique. It worked.

The latest build of this product (v22.1.3) was released 27 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.