Skip to content

Instantly share code, notes, and snippets.

@KevinGutowski
Last active June 14, 2020 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KevinGutowski/1f2ccef06eeba0c7ffa8145bb8fe4ee2 to your computer and use it in GitHub Desktop.
Save KevinGutowski/1f2ccef06eeba0c7ffa8145bb8fe4ee2 to your computer and use it in GitHub Desktop.
Attach modal to Sketch document
let window = document.sketchObject.window()
let fiber = coscript.createFiber()
let alert = NSAlert.alloc().init()
alert.addButtonWithTitle("OK")
alert.addButtonWithTitle("Cancel")
alert.setMessageText("This is the message text")
alert.setInformativeText("This is some extra informative text")
alert.setAlertStyle(NSAlertStyleWarning)
alert.beginSheetModalForWindow_completionHandler(window,__mocha__.createBlock_function(
'v16@?0q8',
(returnCode) => {
try {
handleReturnCode(returnCode)
} catch (err) {
console.error(err)
}
NSApp.endSheet(alert)
if (fiber) {
fiber.cleanup()
}
})
)
function handleReturnCode(returnCode) {
if (returnCode == NSAlertFirstButtonReturn) {
console.log("Success")
} else {
console.log("nope")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment