]> khamidou — GitHub mirrors - electron.git/commitdiff
On OS X the "Cancel" is always get selected when dialog is cancelled
authorCheng Zhao <zcbenz@gmail.com>
Tue, 7 Jul 2015 10:45:43 +0000 (18:45 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 7 Jul 2015 10:45:43 +0000 (18:45 +0800)
atom/browser/api/lib/dialog.coffee

index 3dbd80a25ef35724471452dbf97c7eb3cce34aa6..6ee334e29a53372d84ee9c585e523c03000e741b 100644 (file)
@@ -93,6 +93,7 @@ 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
@@ -100,6 +101,12 @@ module.exports =
           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,