Last active
November 25, 2020 11:42
-
-
Save KevinGutowski/dbcedd20696f6175b52f8ce4d276d035 to your computer and use it in GitHub Desktop.
Progressbar modal
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 documentWindow = NSApplication.sharedApplication().mainWindow() | |
let mySheetWindow = NSWindow.alloc().initWithContentRect_styleMask_backing_defer( | |
NSMakeRect(0, 0, 300, 50), | |
(NSWindowStyleMaskTitled | NSWindowStyleMaskDocModalWindow), | |
NSBackingStoreBuffered, | |
true | |
) | |
let progressView = NSProgressIndicator | |
.alloc() | |
.initWithFrame(NSMakeRect(20, 20, 260, 12)) | |
progressView.setControlTint(NSBlueControlTint) | |
progressView.startAnimation(true) | |
mySheetWindow.contentView().addSubview(progressView) | |
documentWindow.beginSheet_completionHandler(mySheetWindow, nil) | |
// put your long running code here | |
// once its done executing | |
// close the sheet | |
setTimeout(function() { | |
documentWindow.endSheet(mySheetWindow) | |
}, 1000 * 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment