wails icon indicating copy to clipboard operation
wails copied to clipboard

Webview failed to set AllowExternalDrag to false on Win 10 ( after cross compile on macOS)

Open barats opened this issue 4 months ago • 8 comments

Description

I am developing a Wails application on the macOS platform. I cross-compile the executable file on macOS and run it on a Windows 10 system (with -windowsconsole -platform windows/amd64 options so that I could check output details), basically there are 2 main issues:

1. WebView failed to set AllowExternalDrag to false If AllowExternalDrag is not disabled, WebView will automatically open the files that are dragged into it. But frontend projects can not handle full path of file, so I have to disable WebView DnD and handle files at the backend.

2. Wails backend runtime.OnFileDrop(ctx, func(x, y int, paths []string) doesn't work Registered necessary listener onStartup and then onDomReady, but didn't see any evidence that events been triggered.

Build scripts on macOS is : wails build -clean -windowsconsole -platform windows/amd64

Disabled DnD at Wails app options:

DragAndDrop: &options.DragAndDrop{
                EnableFileDrop:     true,
                DisableWebViewDrop: true,
        },
Windows: &windows.Options{
                Theme:                windows.Light,
                WindowIsTranslucent:  false,
                WebviewIsTransparent: false,
                WebviewUserDataPath:  "",
        },

Listen for coming events when DOM ready:

OnDomReady: func(ctx context.Context) {
        some_manager.StartOnFileDrop(ctx) // call runtime.OnFileDrop(ctx, func(x, y int, paths []string) and handle file paths
},

To Reproduce

  1. Build windows/amd64 app on macOS
  2. Move .exe files to Win10 and double click to run
  3. Drag and drop files into app window

Expected behaviour

  1. WebView DnD should be disabled
  2. Backend DnD events should be called

Screenshots

No response

Attempted Fixes

No response

System Details

# Wails
Version | v2.9.2

# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                                                                   |
| Version      | 15.0                                                                                                                                                                    |
| ID           | 24A335                                                                                                                                                                  |
| Go Version   | go1.21.0                                                                                                                                                                |
| Platform     | darwin                                                                                                                                                                  |
| Architecture | amd64                                                                                                                                                                   |
| CPU          | Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz                                                                                                                              |
| GPU          | Chipset Model: Intel Iris Plus Graphics Type: GPU Bus: Built-In VRAM (Dynamic, Max): 1536 MB Vendor: Intel Device ID: 0x8a53 Revision ID: 0x0007 Metal Support: Metal 3 |
| Memory       | 16GB                                                                                                                                                                    |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version        |
| Xcode command line tools  | N/A          | Installed | 2409           |
| Nodejs                    | N/A          | Installed | 20.15.1        |
| npm                       | N/A          | Installed | 10.7.0         |
| *Xcode                    | N/A          | Installed | 16.0 (16A242d) |
| *upx                      | N/A          | Installed | upx 4.1.0      |
| *nsis                     | N/A          | Installed | v3.10          |
└─────────────────────── * - Optional Dependency ───────────────────────┘

# Diagnosis
 SUCCESS  Your system is ready for Wails development!

Additional context

No response

barats avatar Sep 26 '24 07:09 barats