Expand description
File dialogs as an ask: the app describes an Open, Save or folder
dialog, the host shows the platform’s own, and the answer comes back as
one {kind:"files", paths, tag} event (paths empty when cancelled).
Build a FileDialog and hand it to Ui::request_files from a view or
Core::request_files between frames. The core cannot show a dialog, so
it queues the ask; the windowed runner drains it and answers for you,
while a host driving its own window drains Core::take_file_requests
and answers with InputEvent::Files. One ask is out at a time: a
second while one is unanswered is dropped, so a view that asks every
frame until the answer lands asks once.
use kui_core::{Core, FileDialog, FileDialogMode, InputEvent};
let dialog = FileDialog::open()
.multiple()
.title("Add images")
.filter("Images", &["png", "jpg"])
.tag("import");
let mut core = Core::new();
assert!(core.request_files(dialog));
// A host without the runner: drain the ask, show the dialog, answer.
let asked = core.take_file_requests();
assert_eq!(asked[0].mode, FileDialogMode::Open);
let events = core.handle_input(InputEvent::Files(vec!["/tmp/a.png".into()]));
assert_eq!(events[0].kind(), Some("files"));Structs§
- File
Dialog - An Open, Save or folder dialog, as an app asks for one.
- File
Filter - One entry of a dialog’s file-type menu:
Imagesoverpng,jpg. Extensions are without the dot.
Enums§
- File
Dialog Mode - What a dialog picks.