Unable to drop files on an AllowDrop-enabled Grid. (even with [STAThread])
See original GitHub issueDescribe the bug It seems to be impossible to drag and drop an external file or highlighted text onto a control that has DragDrop.AllowDrop set to true. I have tried this on the ControlCatalog’s Drop page (from master), and also on a clean project that has nothing but a drop surface (0.10.0-rc1).
The dragged item seems to ‘fall through’ the Avalonia window, as in whatever is behind it (desktop, another program) is receiving both the mouse movement and the mouse release (drop) events. For example, if the only thing behind the Avalonia Window is the Desktop, then trying to drag and drop a file on the window will just move the file to the desktop to a spot behind the window. This ‘ghost window’ behavior only seems to happen when dragging files, but even if I drag a piece of text over the window, still no events are received.
To Reproduce
- Clone the project from either master (3c22ce5) or 0.10.0-rc1
- Build the project and the control catalog
- Go to “Drag+Drop” page
- Try to drop a file or text on the dark blue rectangle.
- The file will instead be dropped on whatever is behind the window.
Expected behavior I would expect the DragOverEvent event to fire when I drag an item over the window, and the DropEvent should also fire when I release the item while hovering above a drop-enabled surface.
Screenshots
You can see pretty much all relevant information on this screenshot. I am trying to drop a file on the window, but instead of it, my IDE is receiving the mouse events, and it’s highlighting the line (MainWindow.ctor()) where it thinks I’m trying to drop the file.
Desktop:
- OS: Manjaro Linux, KDE Plasma, SDDM, Xorg, kernel 5.9
- Version 0.10.0-rc1 (also reproduced on ControlCatalog at master/3c22ce5)
- SDK: 3.1.401
Additional context I have seen similar issues posted by other people in the past, and adding the [STAThread] attribute on Main() seemed to be a solution for all of them. In my case, adding the attribute didn’t change anything.
EDIT: There is one small mistake on the screenshot, where one handler is added to this
and the other is added to grid
. This was just a mistake when I took the screenshot. I have tried adding the two handlers to both this
and to grid
.
EDIT 2: After some experimentation, I noticed that there are some other programs that are affected by this bug. For example, the window that appears after the display
command (from ImageMagick) is also affected. I’m calling it a bug because a drop event should never fall through a window, even if the window doesn’t want to handle it. Now I don’t know if this is a bug in Avalonia or in my desktop environment/window manager.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
still waiting for the official support…
I think we haven’t yet added file DnD for Linux. Windows and OSX should work.