🍎 Add additional options for Mac's open dialog

Support an additional attributes available in macOS's NSOpenPanel:
message.
This commit is contained in:
Tan Wang Leng 2017-02-02 00:01:01 +08:00
parent cc22149beb
commit 36209ddd90
8 changed files with 29 additions and 9 deletions

View file

@ -81,7 +81,8 @@ module.exports = {
}
}
let {buttonLabel, defaultPath, filters, properties, title} = options
let {buttonLabel, defaultPath, filters, properties, title,
message} = options
if (properties == null) {
properties = ['openFile']
@ -118,11 +119,18 @@ module.exports = {
filters = []
}
if (message == null) {
message = ''
} else if (typeof message !== 'string') {
throw new TypeError('Message must be a string')
}
const wrappedCallback = typeof callback === 'function' ? function (success, result) {
return callback(success ? result : void 0)
} : null
return binding.showOpenDialog(title, buttonLabel, defaultPath, filters,
dialogProperties, window, wrappedCallback)
dialogProperties, message, window,
wrappedCallback)
},
showSaveDialog: function (...args) {