I have a container control containing a canvas. On the canvas are a number of controls such as buttons and textareas. I want the user to be able to drop a file anywhere on the canvas (including on any of the controls on the canvas) and have the canvas’s dropobject event fire. The canvas has me.AcceptFileDrop("special/any") in its open event.
This works OK if the drop takes place on the canvas itself or on a button. But if the drop is on a textarea then the file’s path is added to the textarea’s content.
How do I prevent this and have the drop handled by the canvas? I tried having a dragenter event on a textarea and, whether I return true or false, makes no difference.
macOS has a system wide drag and drop text functionality. You can select text, and drag it between any text entry in almost any app because of it. This functionality also allows the drag and drop of files to turn their path into text (TextEdit, Terminal) or accept their filename.
You’re probably looking for a declare if you really really want to turn it off, that or make the TextArea ReadOnly.
DropObject is the event you need to deal with for the Text Area
Open the file, extract the contents, and put it into the TextArea.
Sub DropObject(obj As DragItem, action As Integer) Handles DropObject
if obj.TextAvailable then
else if obj.FolderItemAvailable then
dim txtStream as TextInputStream