Uh, nope. I added the DragOver code below (again copied directly from the DragAndDrop example (although I removed the URL portion) and still can't drag an image onto the ImageView.
Sub ImgTarget_DragOver(e As DragEvent)
If e.GetDragboard.HasImage Then
e.AcceptTransferModes(TransferMode.COPY)
Return
End If
If e.GetDragboard.HasFiles Then
Dim Found As Boolean = False
For Each F As String In e.GetDragboard.GetFiles
If F.EndsWith(".jpg") Then Found = True
If F.EndsWith(".png") Then Found = True
Next
If Found Then
e.AcceptTransferModes(TransferMode.COPY)
Return
End If
End If
End Sub
I don't see how adding the DragOver sub would matter if the DragEntered sub isn't being called. A break point on the first statement in the ImgTarget_DragEntered sub never gets hit which does indicate that the DragEntered sub isn't being called.
As a test, I added a TextArea and set it up to accept a DragAndDrop...
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private DragDrop1 As DragAndDrop
Private DragDrop2 As DragAndDrop
Private ImageIndex As Int
Private ImgTarget As ImageView
Private TxtTarget As TextArea
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
DragDrop1.Initialize(Me)
DragDrop1.MakeDragTarget(TxtTarget, "TxtTarget")
DragDrop2.Initialize(Me)
DragDrop2.MakeDragTarget(ImgTarget, "ImgTarget")
End Sub
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub
Sub ImgTarget_DragEntered(e As DragEvent)
Log("ImgTDragEntered")
End Sub
Sub TxtTarget_DragEntered(e As DragEvent)
Log("TxtTDragEntered")
End Sub
When I drag something onto the TextArea, the log shows the TxtTDragEntered message as it should. Yet the same code doesn't seem to work for the ImageView, the ImgTDragEntered message never shows in the log.
Next, if I replace the ImageView with a Canvas, the code works correctly and I get the ImgTDragEntered message when I drag something onto the canvas. So why would it work with a Canvas but not with an ImageView?