Skip to content

can't listen to tauri events in rust #2901

@FabianLars

Description

@FabianLars

Describe the bug

listening to tauri events (https://github.com/tauri-apps/tauri/blob/next/tooling/api/src/event.ts#L26) is not possible in rust via the .listen/.listen_global methods.
imo this is fine for window events as i feel like .on_window_event should be preferred here anyway, but unfortunately this makes the file drop and updater events completely inaccessible in rust.

Tried to look into it myself, but was to impatient to find the issue lol (aka didn't find it at first glance).
Also i'm not sure if it's actually desirable to reintroduce this way to listen to tauri events (as we have .on_(window|menu)_event hooks now).

To Reproduce

Add the following to the App Builder and drop files into the window.

.on_page_load(|window, _| {
    window.listen("tauri://file-drop", |event| {
        dbg!(event);
    });
})

Platform and Versions (required):

same behavior on current release and next branch.

Operating System - Windows, version 10.0.19043 X64
Webview2 - 95.0.1020.53

Node.js environment
Node.js - 16.13.0
@tauri-apps/cli - 1.0.0-beta.10
@tauri-apps/api - 1.0.0-beta.8

Global packages
npm - 8.0.0
yarn - 1.22.15

Rust environment
rustc - 1.56.1
cargo - 1.56.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions