Skip to main content

Module file_dialog

Module file_dialog 

Source
Expand description

File dialogs: asking the user to pick or name a file from the platform’s own panel.

The Host does not call the platform. The Renderer owns the windows and the platform’s panel, so a request crosses as a command record in an ordinary batch, and the answer comes back as an ordinary event. A dialog is not a node: it has no place in the tree and it is gone once it has answered.

Every request gets exactly one answer, whether the user chose, cancelled, or this run has no way to show a panel. The Host numbers each request, remembers the callback under that number, calls it once when the matching event arrives, and drops it. An answer for a number nobody is waiting on is ignored.

ⓘ
FileDialog::open_files()
    .title("Choose files to send")
    .filter("Images", &["png", "jpg"])
    .show(|result| {
        if let FileDialogResult::Chosen { paths, .. } = result {
            send(paths);
        }
    });

FileDialog::show belongs on the Renderer’s UI thread, from a handler or a component, because its callback runs there. A worker thread asks through FileDialogSender, whose callback has to be Send for the same reason: it is stored by the Host and called on the UI thread. Nothing here is a queue on the boundary. The queue is the Host’s own and it is written into the next batch inside a call.

Structs§

FileDialog
One file dialog, built and then shown.
FileDialogSender
A handle a worker thread asks for dialogs through.

Enums§

FileDialogResult
How a dialog ended.