From 47e0a61dd8a843beb55542961a1e855d8ff6c815 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 6 Aug 2014 15:00:31 +0800 Subject: [PATCH] docs: Document the filters option. --- docs/api/dialog.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/api/dialog.md b/docs/api/dialog.md index ad3b2e62221d..1778e8fb3a82 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -19,6 +19,7 @@ console.log(dialog.showOpenDialog({ properties: [ 'openFile', 'openDirectory', ' * `options` Object * `title` String * `defaultPath` String + * `filters` Array * `properties` Array - Contains which features the dialog should use, can contain `openFile`, `openDirectory`, `multiSelections` and `createDirectory` @@ -27,6 +28,19 @@ console.log(dialog.showOpenDialog({ properties: [ 'openFile', 'openDirectory', ' On success, returns an array of file paths chosen by the user, otherwise returns `undefined`. +The `filters` specifies an array of file types that can be displayed or +selected, an example is: + +```javascript +{ + filters: [ + { name: 'Images', extensions: ['jpg', 'png', 'gif'] }, + { name: 'Movies', extensions: ['mkv', 'avi', 'mp4'] }, + { name: 'Custom File Type', extensions: ['as'] }, + ], +} +``` + If a `callback` is passed, the API call would be asynchronous and the result would be passed via `callback(filenames)` @@ -41,11 +55,15 @@ be showed. * `options` Object * `title` String * `defaultPath` String + * `filters` Array * `callback` Function On success, returns the path of file chosen by the user, otherwise returns `undefined`. +The `filters` specifies an array of file types that can be displayed, see +`dialog.showOpenDialog` for an example. + If a `callback` is passed, the API call would be asynchronous and the result would be passed via `callback(filename)`