Skip to main content

select-file

Description

Fires when selecting a file

Usage

"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 files
  • toggle - (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 default
  • range - (optional) if set to true, enables adding items to the selection range (for example, by holding Shift while selection); the default value is false
  • panel - (optional) the panel number where an item is selected (0|1); by default, the active panel number is set
  • type - (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