Instead of dynamically writing AppleScript and then piping it into the binary, I decided to write a native module that uses CoreFoundation to display a dialog. Please open an issue if you have any feature requests or encounter any bugs!
var dialog = require('osx-dialog')
dialog({
title: 'A Title',
msg: 'some message',
timeout: 10,
checkboxes: [
'first box',
'second box'
]
}, function (error, button, checkboxes) {
// do stuff with the result.
})
###dialog(options, [callback])
options
(required) has the following keystitle
(required) is the bolded portion of the dialogmessage
(required) is the text area portion of the dialogtimeout
(optional) is the duration in seconds the dialog should be displayed before it is dismissedcheckboxes
(optional) is an array of strings that will be displayed as checkboxes
callback
(optional) has the signaturecallback(error, button, checkboxes)
error
will benull
or a string with the error messagebutton
will be a boolean noting if it was dismissed by hitting the button (true
) or dismissed by hitting escape (false
)checkboxes
will be an array of booleans with the status of the checkboxes in the order that was given todialog
- Be able to set the buttons.
- Be able to use radio types.