docs: Document the filters option.

This commit is contained in:
Cheng Zhao 2014-08-06 15:00:31 +08:00
parent 5ba324ca9a
commit 47e0a61dd8

View file

@ -19,6 +19,7 @@ console.log(dialog.showOpenDialog({ properties: [ 'openFile', 'openDirectory', '
* `options` Object * `options` Object
* `title` String * `title` String
* `defaultPath` String * `defaultPath` String
* `filters` Array
* `properties` Array - Contains which features the dialog should use, can * `properties` Array - Contains which features the dialog should use, can
contain `openFile`, `openDirectory`, `multiSelections` and contain `openFile`, `openDirectory`, `multiSelections` and
`createDirectory` `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 On success, returns an array of file paths chosen by the user, otherwise
returns `undefined`. 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 If a `callback` is passed, the API call would be asynchronous and the result
would be passed via `callback(filenames)` would be passed via `callback(filenames)`
@ -41,11 +55,15 @@ be showed.
* `options` Object * `options` Object
* `title` String * `title` String
* `defaultPath` String * `defaultPath` String
* `filters` Array
* `callback` Function * `callback` Function
On success, returns the path of file chosen by the user, otherwise returns On success, returns the path of file chosen by the user, otherwise returns
`undefined`. `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 If a `callback` is passed, the API call would be asynchronous and the result
would be passed via `callback(filename)` would be passed via `callback(filename)`