Skip to content

Instantly share code, notes, and snippets.

@KevinGutowski
Last active November 25, 2020 11:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KevinGutowski/dbcedd20696f6175b52f8ce4d276d035 to your computer and use it in GitHub Desktop.
Save KevinGutowski/dbcedd20696f6175b52f8ce4d276d035 to your computer and use it in GitHub Desktop.
Progressbar modal
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