#FileDropEvent not fires

10 messages · Page 1 of 1 (latest)

wintry bronze
#

Hello, I don't know why but I can't have a match that fit the FileDropEvent

let builder = Builder::new("window").on_event(|app_handle, event| match event {
        RunEvent::WindowEvent {
            event: WindowEvent::Resized(_),
            ..
        } => {
            app_handle.emit_all("resized", ()).unwrap();
        }
        RunEvent::WindowEvent {
            event: WindowEvent::FileDrop(FileDropEvent::Dropped(files)),
            ..
        } => {
            println!("DropEvent {}", files.len());

I have fileDropEnabled:true in my tauri.conf.json
I've tried in the builder of the application with on_window_event but the event does not get catch and instead I the file is open with the webview (At least during dev)

frosty fog
#

instead I the file is open with the webview
That suggests that tauri's file drop handler is indeed disabled. Can you post the output of the tauri info command for a start?

wintry bronze
#

Oh yes my bad, it opens because I did not reapply the stash. So it effectively work as expected, unless if I use it in a plugin (just checking if I have not make the same mistake twice...)

#

[✔] Environment
- OS: Windows 10.0.19045 X64
✔ WebView2: 114.0.1823.58
✔ MSVC: Visual Studio Build Tools 2022
✔ rustc: 1.70.0 (90c541806 2023-05-31)
✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 16.19.1
- pnpm: 8.6.3
- yarn: 1.22.19
- npm: 8.19.3

[-] Packages
- tauri [RUST]: 1.4.1
- tauri-build [RUST]: 1.4.0
- wry [RUST]: 0.24.3
- tao [RUST]: 0.16.1
- @tauri-apps/api [NPM]: 1.4.0
- @tauri-apps/cli [NPM]: 1.4.0

[-] App
- build-type: bundle
- CSP: font-src 'self' https://fonts.gstatic.com; style-src 'self' https://fonts.googleapis.com; connect-src https://identitytoolkit.googleapis.com https://api-js.mixpanel.com https://securetoken.googleapis.com data: https://tauri.localhost tauri://localhost; script-src blob:; default-src 'self'
- distDir: ../dist
- devPath: http://localhost:5173/
- framework: Svelte
- bundler: Rollup

#

So it works on the main builder but not on the plugin::Builder. I use on_window_event on the main and on_event on the plugin

frosty fog
grave agate
#

I don't think it's a bug, I had a similar issue. Setting fileDropEnabled to false fix it as specified https://tauri.app/v1/api/config/#windowconfig see the fileDropEnabled settings and description

The Tauri configuration object. It is read from a file where you can define your frontend assets, configure the bundler, enable the app updater, define a system tray, enable APIs via the allowlist and more.

frosty fog
#

we're not talking about javascript events here

grave agate
#

My bad 😔