[v2] Files DragAndDrop bugs
Description
- When only
EnableFileDrop: true, every time D'n'D happens anOnDomReadyis triggered.
INF | drop files: []string{"/abs/path/file.txt"}
WTF?
main.(*App).onFileDrop
.../app.go:125
github.com/wailsapp/wails/v2/pkg/runtime.OnFileDrop.func1
github.com/wailsapp/wails/[email protected]/pkg/runtime/draganddrop.go:30
runtime.goexit
$GOROOT/src/runtime/asm_amd64.s:1598
INF | DOM READY -------------------------------
WTF?
main.(*App).domReady
.../app.go:104
github.com/wailsapp/wails/v2/internal/frontend/desktop/linux.(*Frontend).processMessage
github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/linux/frontend.go:411
github.com/wailsapp/wails/v2/internal/frontend/desktop/linux.(*Frontend).startMessageProcessor
github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/linux/frontend.go:215
runtime.goexit
$GOROOT/src/runtime/asm_amd64.s:1598
- When
EnableFileDrop: true, DisableWebViewDrop: true, D'n'D don't work for files ever. Not sure how this option should be used. I hoped it should prevent p.1 above to happen. (enhance usage documentation)
To Reproduce
import "github.com/pkg/errors"
func (a *App) domReady(ctx context.Context) {
runtime.OnFileDropOff(ctx)
runtime.LogInfof(ctx, "DOM READY -------------------------------\n%+v", errors.New("WTF?"))
runtime.OnFileDrop(ctx, a.onFileDrop)
}
func (a *App) onFileDrop(x, y int, paths []string) {
runtime.LogInfof(a.ctx, "drop files: %#v\n%+v", paths, errors.New("WTF?"))
}
Expected behaviour
- No extra OnDomReady triggering
- Better documentation how these options works at they own and together.
Screenshots
No response
Attempted Fixes
No response
System Details
# Wails
Version | v2.9.1
Package Manager | apt
(v2.9.2 as well - UPD 2024-10-05)
System
┌──────────────────────────────────────────────────────────────────────────────────┐
| OS | Ubuntu |
| Version | 22.04 |
| ID | ubuntu |
| Go Version | go1.20.5 |
| Platform | linux |
| Architecture | amd64 |
| CPU | AMD Ryzen 9 7950X 16-Core Processor |
| GPU | unknown (Advanced Micro Devices, Inc. [AMD/ATI]) - Driver: amdgpu |
| Memory | 59GB |
└──────────────────────────────────────────────────────────────────────────────────┘
Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version |
| *docker | docker.io | Available | 24.0.7-0ubuntu2~22.04.1 |
| gcc | build-essential | Installed | 12.9ubuntu3 |
| libgtk-3 | libgtk-3-dev | Installed | 3.24.33-1ubuntu2.1 |
| libwebkit | libwebkit2gtk-4.0-dev | Installed | 2.44.2-0ubuntu0.22.04.1 |
| npm | npm | Installed | 10.2.4 |
| *nsis | nsis | Installed | v3.08-2 |
| pkg-config | pkg-config | Installed | 0.29.2 |
└──────────────────────── * - Optional Dependency ─────────────────────────┘
Additional context
No response
Hi @Vovan-VE Plese take a look on this example project showing how to implement this feature: https://github.com/beam-transfer/wails-drag-and-drop/blob/main/README.md#demo
The documentation would benefit from more details for sure.
If you get it working you are in the great position to write an docs for that feature since you just learned what you did not know before. Please please consider submitting PR.
@pavelbinar , the demo works in the same way as described above.
I'll move a code away from DomReady to Startup and so ban DomReady for awhile.
Finally I checked Windows. Drop don't work on Windows 10 at all. Drag works. Drop doesn't.
I have similar issues on Windows 11. I tested it on wails-drag-n-drop.
❌If wails dev is used, no drop events are fired on the go side, but js events are emitted.
✅If wails build -debug is used, then both js and go events are emitted.
Modified code:
// app.go
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
runtime.OnFileDrop(ctx, a.onFileDrop)
}
func (a *App) onFileDrop(x, y int, paths []string) {
runtime.LogInfof(a.ctx, "drop files: %#v\n", paths)
}
System Details
# Wails
Version | v2.9.1
# System
┌────────────────────────────────────────────────────────────────────────┐
| OS | Windows 10 Pro |
| Version | 2009 (Build: 22631) |
| ID | 23H2 |
| Go Version | go1.19.2 |
| Platform | windows |
| Architecture | amd64 |
| CPU | 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz |
| GPU | NVIDIA GeForce RTX 4090 (NVIDIA) - Driver: 31.0.15.5161 |
| Memory | 64GB |
└────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version |
| WebView2 | N/A | Installed | 126.0.2592.113 |
| Nodejs | N/A | Installed | 18.18.0 |
| npm | N/A | Installed | 10.5.0 |
| *upx | N/A | Available | |
| *nsis | N/A | Available | |
└─────────────── * - Optional Dependency ────────────────┘
---
PS C:\Users\crab> systeminfo
OS Name: Microsoft Windows 11 Pro
OS Version: 10.0.22631 N/A Build 22631
Checked in v2.9.2 just now. Both subissues are actual still.
We'll look at this as a priority