Class FVTTFilePickerControl
Index
Constructors
constructor
- new FVTTFile
Picker (): FVTTFilePickerControlControl Returns FVTTFilePickerControl
Accessors
Static
canBrowse
- get canBrowse(): boolean
Returns boolean
Test if the current user can browse files.
Methods
Static
bringToTop
Static
browse
- browse(options?, event?): Promise<string>
Creates a new Foundry FilePicker app to browse and return a file path selection.
Parameters
Optional
options: FVTTFilePickerBrowseOptionsFVTTFilePickerControl browse options. This may also include any Application options.
Optional
event: MouseEvent | KeyboardEventAn event to inspect for focus management when a modal file picker is launched.
Returns Promise<string>
The file picker / browse result.
Static
close
- close(id?): void
Closes the file picker with optional
id
of a specific file picker app to close. You may also provide a list of app IDs to close. When provided only the file picker app instance with a matching ID will be closed.Note: When
close
is invoked w/ noid
parameter any current file picker app is closed.Parameters
Optional
id: string | Iterable<string, any, any>Specific IDs to match against any current visible file picker app.
Returns void
Provides managed control of the Foundry globalThis.FilePicker app simplifying asynchronous use cases. While the stock FilePicker provides a callback it is not easy to make it asynchronous given that a user can close the app. FVTTFilePickerControl enables a fully asynchronous workflow controlling one FilePicker instance at a time. When FVTTFilePickerControl.browse is invoked any previous FilePicker instance is closed and Promise resolved.
Additionally, the file picker app is modified to work in modal context w/ TJSGlassPane along with any managing associated dialog instances displayed. A very powerful capability is to display a modal FilePicker app instance.
For extended options available for FVTTFilePickerControl.browse see FVTTFilePickerBrowseOptions. It is highly recommended that you provide a unique CSS ID for each file picker instance invoked. A use case where you should use FVTTFilePickerControl is to invoke FVTTFilePickerControl.close in an
onDestroy
Svelte callback to close any open file picker apps associated w/ UI layout components you design.A demo example is available in
essential-svelte-esm
: https://github.com/typhonjs-fvtt-demo/essential-svelte-esmSeveral ready-made Svelte components are available that are designed around FVTTFilePickerControl.
Please see the following Svelte components that can be imported from
#standard/component/fvtt/filepicker/button
:See