Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nwutils/nw-programmatic-folder-select
Programmatically open a native "Folder select" dialog
https://github.com/nwutils/nw-programmatic-folder-select
directory-selector nwjs programmatically tool xpda
Last synced: 3 months ago
JSON representation
Programmatically open a native "Folder select" dialog
- Host: GitHub
- URL: https://github.com/nwutils/nw-programmatic-folder-select
- Owner: nwutils
- License: mit
- Created: 2019-08-01T22:20:26.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-30T17:11:55.000Z (about 1 year ago)
- Last Synced: 2024-11-08T23:58:11.680Z (3 months ago)
- Topics: directory-selector, nwjs, programmatically, tool, xpda
- Language: JavaScript
- Homepage: https://nwutils.io
- Size: 200 KB
- Stars: 5
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# nw-programmatic-folder-select
![Build Status](https://github.com/nwutils/nw-programmatic-folder-select/workflows/Node.js%20CI/badge.svg)
Programmatically open a native "Folder select" dialog in NW.js.
Similar to `` but with just JavaScript.
![Windows Screenshot from NW.js 0.12.3](screenshots/win.png)
![Windows Screenshot from NW.js 0.40.0](screenshots/win2.png)
![Ubuntu Screenshot from NW.js 0.40.0](screenshots/ubuntu.png)Compatible with all versions of NW.js.
**Version** | **Tested**
:--: | :--:
v0.12.3 | :heavy_check_mark:
v0.14.7 | :heavy_check_mark:
v0.40.0 | :heavy_check_mark:
v0.83.0 | :heavy_check_mark:Works on all platforms NW.js runs on (Windows, Linux, OSX).
## Installation
```
npm install --save nw-programmatic-folder-select
```## Basic Usage
```js
const openFolderExplorer = require('nw-programmatic-folder-select');
// The window object, to have access to the browser context, and a callback function with the user's choice
openFolderExplorer(window, (selection) => { console.log(selection); });
```## Advanced Usage
```js
const openFolderExplorer = require('nw-programmatic-folder-select');const options = {
// Optional string. The working directory to start in
directory: 'C:\\',
// Optional string. A custom title for the OS's folder selection dialog
title: 'Select a folder to store the settings file in'
};// Optional asynchronous callback function.
// Returns a string to the path, like 'C:\Users\Bob\Desktop', or undefined if no selection made
function callback (selection) {
if (selection) {
console.log('The user chose ' + selection);
} else {
console.log('The user cancelled the dialog.');
}
}// Window is required to have access to the browser context
// All other arguments are optional
openFolderExplorer(window, options, callback);
```