Inserting a code snippet by drag and drop

SyntaxEditor for WPF Forum

Posted 6 years ago by Daisuke Nakada
Version: 17.2.0665
Avatar

Hi, 

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 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

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 6 years ago by Daisuke Nakada
Avatar

Thank you for telling me that technique. It worked.

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.