Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 doesn't receive drag and drop events on the backend #3985

Open
makew0rld opened this issue Jan 7, 2025 · 3 comments
Open

Windows 10 doesn't receive drag and drop events on the backend #3985

makew0rld opened this issue Jan 7, 2025 · 3 comments
Labels
Bug Something isn't working

Comments

@makew0rld
Copy link

makew0rld commented Jan 7, 2025

Description

In the backend I have a drop handler registered with runtime.OnFileDrop. In the frontend I have this, as per here:

addEventListener("drop", (event) => {
  event.preventDefault();
});
addEventListener("dragover", (event) => {
  event.preventDefault();
});

When testing in Windows 10, my backend drop handler never gets run when I drop a file. If I add a console logging line to the drop event in JavaScript however, that does run. So it seems Wails is not propagating the event to the backend properly.

To Reproduce

  1. Clone https://github.com/makew0rld/wails-issue-3985
  2. Build for Windows (I am doing so on Arch Linux): wails build -platform windows/amd64 -windowsconsole -debug
  3. Open the .exe in Windows (a Windows 10 VM in my case)
  4. Open the web console using the right-click menu
  5. Drag in a file
  6. Observe how nothing appears in the backend console, but a drop event appears in the web console

Expected behaviour

Backend drop handlers are triggered on Windows 10.

Screenshots

No response

Attempted Fixes

No response

System Details

These are the details of the system I'm building the binary on.

# Wails
Version         | v2.9.2
Package Manager | pacman

# System
┌───────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Arch Linux                                                             |
| Version      | Unknown                                                                |
| ID           | arch                                                                   |
| Go Version   | go1.23.3                                                               |
| Platform     | linux                                                                  |
| Architecture | amd64                                                                  |
| CPU          | 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz                         |
| GPU          | TigerLake-LP GT2 [Iris Xe Graphics] (Intel Corporation) - Driver: i915 |
| Memory       | 15GB                                                                   |
└───────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌─────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status    | Version                     |
| *docker    | docker       | Installed | 1:27.3.1-1                  |
| gcc        | gcc          | Installed | 14.2.1+r134+gab884fffe3fc-1 |
| libgtk-3   | gtk3         | Installed | 1:3.24.43-4                 |
| libwebkit  | webkit2gtk   | Installed | 2.46.4-1                    |
| npm        | npm          | Installed | 10.9.2-1                    |
| pkg-config | pkgconf      | Installed | 2.3.0-1                     |
└────────────────────── * - Optional Dependency ──────────────────────┘

# Diagnosis
 SUCCESS  Your system is ready for Wails development!

Additional context

Seems related to #3782 but I wanted to create a new thread because that one is all over the place.

Unfortunately using the JavaScript handler is not really an option in my case as I would like to open the file directly on the user's system for efficiency and JavaScript doesn't give the full file path.

@makew0rld makew0rld added the Bug Something isn't working label Jan 7, 2025
@makew0rld
Copy link
Author

makew0rld commented Jan 7, 2025

I was informed on Discord that setting any sort of JavaScript Wails drop handler would cause the event to propagate to the backend. And indeed this fixed it for me:

// In main.js
// Empty callback function
runtime.OnFileDrop(function (x, y, paths) {}, false);

To me this is unexpected behaviour though, and ideally the backend handler would always be triggered. This would match behaviour on other OSes.

@leaanthony
Copy link
Member

I'm curious as to why Linux needs that. A workaround would be just to execute this on runtime load if the option has been set. I'd accept a PR for that if you're comfortable raising it?

@makew0rld
Copy link
Author

I assume you mean Windows. I can try and look into a PR for this although #3949 may fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants