select-file
Description
Fires when selecting a fileUsage
"select-file": ({
id: string,
toggle?: boolean,
range?: boolean,
panel?: 0|1,
type?: "navigation"
}) => boolean | void;
Parameters
The callback of the select-file action takes an object with the following parameters:
ids
- (required) an id of selected filestoggle
- (optional) it's set to true to enable the invert selection of the target item (for example, by holding Ctrl unselects the selected item and adds unselected ones to the selection); it's set to false by defaultrange
- (optional) if set to true, enables adding items to the selection range (for example, by holding Shift while selection); the default value is falsepanel
- (optional) the panel number where an item is selected (0|1); by default, the active panel number is settype
- (optional) the readonly parameter which value is set to "navigation" and it's activated when the back-to-parent, control is activated
Example
<script>
import { getData, getDrive } from "./common/data";
import { Filemanager } from "wx-svelte-filemanager";
let api;
$: if (api) {
api.on("select-file", ({ id, toggle, range }) => {
console.log(`Selected file" is ${id} with the toggle value = ${toggle} and the range value = ${range}` );
});
};
</script>
<Filemanager data={getData()} drive={getDrive()} bind:api />
Related articles: How to access File Manager API