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

[v2] Files DragAndDrop bugs #3563

Open
Vovan-VE opened this issue Jun 23, 2024 · 6 comments
Open

[v2] Files DragAndDrop bugs #3563

Vovan-VE opened this issue Jun 23, 2024 · 6 comments
Labels
Bug Something isn't working

Comments

@Vovan-VE
Copy link
Contributor

Vovan-VE commented Jun 23, 2024

Description

  1. When only EnableFileDrop: true, every time D'n'D happens an OnDomReady is 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
  1. 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

  1. No extra OnDomReady triggering
  2. 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

@Vovan-VE Vovan-VE added the Bug Something isn't working label Jun 23, 2024
@pavelbinar
Copy link
Contributor

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.

@Vovan-VE
Copy link
Contributor Author

@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.

@Vovan-VE
Copy link
Contributor Author

Finally I checked Windows. Drop don't work on Windows 10 at all. Drag works. Drop doesn't.

@shtrih
Copy link

shtrih commented Aug 10, 2024

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

@Vovan-VE
Copy link
Contributor Author

Vovan-VE commented Oct 5, 2024

Checked in v2.9.2 just now. Both subissues are actual still.

@leaanthony
Copy link
Member

We'll look at this as a priority

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

4 participants