question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to drop files on an AllowDrop-enabled Grid. (even with [STAThread])

See original GitHub issue

Describe 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

  1. Clone the project from either master (3c22ce5) or 0.10.0-rc1
  2. Build the project and the control catalog
  3. Go to “Drag+Drop” page
  4. Try to drop a file or text on the dark blue rectangle.
  5. 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 image 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:open
  • Created 3 years ago
  • Reactions:5
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
AnonymousWalkercommented, Jun 16, 2021

still waiting for the official support…

3reactions
kekekekscommented, Jan 10, 2021

I think we haven’t yet added file DnD for Linux. Windows and OSX should work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found