This project is read-only.

Drag And Drop

Topics: Developer Forum, User Forum
Oct 28, 2009 at 11:13 PM

I am currently using the Scintilla control in a vb.NET 2008 Project.  Although i define the AllowDrop property, none of the Drag or Drop events seems to be firing.  I read in the discussions that this was known issue a while back.  Is this still the case?

If so, does anyone know any work arounds?

 

 

Oct 29, 2009 at 12:57 AM

Drag and drop should be working. What version are you using (hopefully 2.2 release)? And can you please upload a small example project? Lastly are you attempting to drag from within the same app or drag a file from explorer onto it?

Oct 29, 2009 at 1:28 AM

>>ChrisLastly are you attempting to drag from within the same app or drag a file from explorer onto it?
I was wondering why that feature is using the default AllowDrop, instead of a new property AllowFileDrop.

Best regards,
Paul. 

Oct 29, 2009 at 2:08 AM

AllowDrop doesn't seem to do much. It just ran some tests:

If AllowDrop is true you can drag files from explorer onto Scintilla. The mouse will change but no WinForm drag events fire. When released the FileDrop event (from Scintilla's UriDropped notification) gets fired but no WinForm drop event fires.

If AllowDrop is false Scintilla pretty much ignores all drops from explorer.

For drops within the same app (AllowDrop seems to be ignored):

If a drag operation from another control is initiated then dragged over Scintilla the cursor changes. No WinForm events fire. When the mouse is released if there was text in the DataObject it gets inserted at the caret position. No FileDrop event or WinForm events get fired. Clearly this needs more work but the complexities are over my head. Scintilla is obviously interfering with Windows Forms Drag operations, I just don't know how to stop it. I wouldn't mind completely bypassing Scintilla's drag logic in favor of Windows Forms since it is a superset of functionality. It's seems complicated due to Windows Forms relying on OleDragDrop whereas Scintilla only handles Win32 Drag messages.

Oct 29, 2009 at 4:29 AM

>>ChrisScintilla is obviously interfering with Windows Forms Drag operations, I just don't know how to stop it.
It is simply doing its job, something simple C applications like NotePad2 will be grateful for :) 

>>Chris It's seems complicated due to Windows Forms relying on OleDragDrop whereas Scintilla only handles Win32 Drag messages.
Scintilla also uses the OleDragDrop, so the Control.AllowDrop call to the RegisterDragDrop, when set to true, is most likely
returning DRAGDROP_E_ALREADYREGISTERED, the value of which is -2147221247, and the Control.AllowDrop will not throw an
exception - take a look in Reflector.

Unlike the RichTextBox, the Scintilla does not expose any OLE equivalent of IRichEditOleCallback, which the .NET RichTextBox implements
and manually calls the Control drag/drop event "raisers".

You might have to find some way to hack it, or simply do what I am doing....
1. Use AllowFileDrop property for the file drop operations, 
2. Use AllowDrop for other drag/drop operations and extend Scintilla source to send the drag/drop messages as notifications.

RichTextBox, for instance uses EnableAutoDragDrop property to complete its native support.

Best regards,
Paul.
 

Oct 29, 2009 at 4:55 PM
ChrisRickard wrote:

For drops within the same app (AllowDrop seems to be ignored):

If a drag operation from another control is initiated then dragged over Scintilla the cursor changes. No WinForm events fire. When the mouse is released if there was text in the DataObject it gets inserted at the caret position. No FileDrop event or WinForm events get fired. Clearly this needs more work but the complexities are over my head. Scintilla is obviously interfering with Windows Forms Drag operations, I just don't know how to stop it. I wouldn't mind completely bypassing Scintilla's drag logic in favor of Windows Forms since it is a superset of functionality. It's seems complicated due to Windows Forms relying on OleDragDrop whereas Scintilla only handles Win32 Drag messages.

Thanks for the quick responses.   I am using version 2.2.   

I am trying to implement the D&D functionality within the application from a tree control to the Scintilla NET control.  Unfortunately I am seeing the behavior you are describing.  I am simply putting a NODE.TEXT value in the Clipboard when an NODE is dragged from the Treeview, but when I drag over the Scintilla control the cursor doesn’t change, nor does the text get written when I release the mouse.  I have tried turning the AllowDrop on & off, no difference.

It worked for you so I am assuming I am missing something simple.  Not to complicated a process so it has to be something simple.   I would be OK with it just working without the events firing since I am looking to do exactly what it does.  Just doesn’t seem to be working for me.

Any ideas?

Oct 29, 2009 at 6:17 PM

>>It is simply doing its job, something simple C applications like NotePad2 will be grateful for :)
Agreed :)

>>You might have to find some way to hack it, or simply do what I am doing....
Do you have something you'd like to share?

Oct 29, 2009 at 6:36 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 29, 2009 at 6:38 PM

I moved this to an issue because it allows attachments. I attached a sample c# project that does what I think you want

 

Oct 29, 2009 at 7:03 PM

>>ChrisDo you have something you'd like to share?
It is not ready yet, I am targeting the end of next month to release an alpha of my project,
and hope to get it ready by then.

I do not think there will be any problem with ikky's needs. If his implementations of the drag/drop
for the tree view is complete, the ScintillaNET would normally accept the dropped text, since it is an
OLE drop target, whether you set AllowDrop or not.
I tested the drag/drop between ScintillaNET and the .NET RichTextBox yesterday (29 Oct), and there was no problem.

I think he should test his implementation with RichTextBox, and see if it works. He only needs the drag/drop events
of the editor if he has to format the dropped text or other text logic. If possible, let him post a sample, we might
be able to help him even with the current ScintillaNET. 

Best regards,
Paul. 

Oct 29, 2009 at 8:20 PM
ChrisRickard wrote:

I moved this to an issue because it allows attachments. I attached a sample c# project that does what I think you want

 

 Thank you thank you thank you...  Turns out i was using the DragDropEffect.Move instead of the DragDropEffects.Copy on the DoDragDrop call.

I knew it would be something little that i was overlooking.

Thanks for all the help, Scintilla is a really great control....  Awesome job to all those involved...

Feb 23, 2011 at 11:26 PM

I am using the latest version and I am having the same problem.  Setting AllowDrop to true and then handling the DrapDrop event does nothing.  No event fires and nothing happens.  However tapping into the file drop even does seem to work.  Why I have to tap into a separate event other than the standard DrapDrop I don't know.

Jul 29, 2011 at 7:07 PM

Same problem for me, too.  The control handles drops of text without firing any events, which is why the example above with the tree control works.  Lack of enter and drop events is just a killer limitation for me.

Jul 29, 2011 at 7:25 PM

I never have come up with a 100% solution for drag and drop. The complexities of the Native Scintilla control trying to do Win32 messaging drag drop coupled with Windows Forms wanting to do COM based drag drop is just too squirrelly.