pub trait EventContextFileDialogExt {
// Required methods
fn pick_file(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>;
fn pick_files(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>;
fn pick_folder(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>;
fn save_file(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>;
}Expand description
Convenience methods on EventContext for opening native file
dialogs. Brings the four shapes (open file, open files, pick
folder, save file) into scope as ctx.pick_file(req, |result| ...)
without forcing every caller to look up the handle and poster
from app-state by hand.
Apps use teksilo_platform::file_dialog::EventContextFileDialogExt
(or use teksilo::prelude::* once the umbrella re-exports it).
All four methods perform the same internal sequence:
- (macOS only) focus the current window so the panel comes to front for non-bundled binaries.
- Stamp the parent handle into the request.
- Look up
FileDialogHandleand theteksilo_core::AppEventPostervia app-state. - Forward to
FileDialogHandle::submit.
Returns Err only when the request fails validation
(FileDialogRequest::validate) or when the framework was not
initialised with a FileDialogHandle (i.e. the application
did not call TeksiloAppBuilder::install_file_dialog).
Convenience method overrides the request kind. The method you
call dictates the operation: ctx.pick_file(req, …) always opens
a single-file picker even if req was built with
FileDialogRequest::save_file. Each method overwrites
request.kind so the FileDialogResult variant returned to the
callback always matches the method name. To control the kind
explicitly, call FileDialogHandle::submit directly with a
pre-built request.
Required Methods§
Sourcefn pick_file(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>
fn pick_file( &mut self, request: FileDialogRequest, on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static, ) -> Result<RequestId, String>
Open a single-file dialog parented to the current window.
on_result runs on the main thread on dialog completion or is
dropped if the originating window closes first.
The request’s kind is forced to PickFile regardless of how
it was constructed — see the trait-level docs.
Sourcefn pick_files(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>
fn pick_files( &mut self, request: FileDialogRequest, on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static, ) -> Result<RequestId, String>
Open a multi-file selection dialog. The request’s kind is
forced to PickFiles. See Self::pick_file.
Sourcefn pick_folder(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>
fn pick_folder( &mut self, request: FileDialogRequest, on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static, ) -> Result<RequestId, String>
Open a folder picker. The request’s kind is forced to
PickFolder. See Self::pick_file.
Sourcefn save_file(
&mut self,
request: FileDialogRequest,
on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static,
) -> Result<RequestId, String>
fn save_file( &mut self, request: FileDialogRequest, on_result: impl FnOnce(FileDialogResult, &mut EventContext<'_>) + 'static, ) -> Result<RequestId, String>
Open a save dialog. The request’s kind is forced to
SaveFile. See Self::pick_file.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".