Last active
June 14, 2020 06:23
-
-
Save KevinGutowski/1f2ccef06eeba0c7ffa8145bb8fe4ee2 to your computer and use it in GitHub Desktop.
Attach modal to Sketch document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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