Merge pull request #2146 from atom/cancel-id

Add "cancelId" option for showMessageBox
This commit is contained in:
Cheng Zhao 2015-07-08 10:08:39 +08:00
commit fdc01b8ba8
7 changed files with 52 additions and 28 deletions

View file

@ -93,8 +93,23 @@ module.exports =
options.detail ?= ''
options.icon ?= null
# Choose a default button to get selected when dialog is cancelled.
unless options.cancelId?
options.cancelId = 0
for text, i in options.buttons
if text.toLowerCase() in ['cancel', 'no']
options.cancelId = i
break
# On OS X the "Cancel" is always get selected when dialog is cancelled.
if process.platform is 'darwin'
for text, i in options.buttons when text is 'Cancel'
options.cancelId = i
break
binding.showMessageBox messageBoxType,
options.buttons,
options.cancelId,
[options.title, options.message, options.detail],
options.icon,
window,