Posted 18 years ago by Paul Hasselfeldt
Avatar
ActiproSoftware.SyntaxEditor.Net20, Version=3.1.211.0

Needing some help getting the drag and drop operations to work within the editor. I have tried using the PasteDragDrop event which will fire and go through the first "if" in the code below, setting the e.DragEventArgs.Effect property and all but it will not change the cursor and a second event is never fired to detect the drop. Also I can't seem to get the DragEnter and DragDrop events to fire either.

        private void editor_PasteDragDrop(object sender, PasteDragDropEventArgs e)
        {
            if (e.Source == PasteDragDropSource.DragEnter)
            {
                object files = e.DataObject.GetData(DataFormats.FileDrop);
                if ((files is string[]) && (((string[])files).Length > 0))
                {
                    string sFile = ((string[])files)[0];

                    if (sFile.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
                        e.DragEventArgs.Effect = DragDropEffects.Copy;
                }
            }
            else if (e.Source == PasteDragDropSource.DragDrop)
            {
                OpenFile(((string[])e.DataObject.GetData(DataFormats.FileDrop))[0]);
            }
        }
Thanks,

Paul

Comments (1)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
we don't raise the DragXXX events because those don't handle caret movement, view switching, etc. appropriately. Instead, we provide the PasteDragDrop event, which has some extremely complex logic behind the scenes to do all those things automatically.

I think you have everything set up ok but the problem is that you didn't set e.Text to be a non-null value in the DragEnter source handler. You can set it to anything non-null to tell SyntaxEditor that there is valid text ready to be dropped.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.