Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

nwutils/nw-programmatic-folder-select

Repository files navigation

nw-programmatic-folder-select

Build Status

Programmatically open a native "Folder select" dialog in NW.js.

Similar to <input type="file" nwdirectory> but with just JavaScript.

Windows Screenshot from NW.js 0.12.3 Windows Screenshot from NW.js 0.40.0 Ubuntu Screenshot from NW.js 0.40.0

Compatible with all versions of NW.js.

Version Tested
v0.12.3 ✔️
v0.14.7 ✔️
v0.40.0 ✔️
v0.83.0 ✔️

Works on all platforms NW.js runs on (Windows, Linux, OSX).

Installation

npm install --save nw-programmatic-folder-select

Basic Usage

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

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);

About

Programmatically open a native "Folder select" dialog

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.