Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created July 17, 2012 01:33
Show Gist options
  • Save fjolnir/3126350 to your computer and use it in GitHub Desktop.
Save fjolnir/3126350 to your computer and use it in GitHub Desktop.
nsapp = NSApplication sharedApplication
\ Create the menubar
menuBar = NSMenu new
appMenuItem = NSMenuItem new
menuBar addItem: appMenuItem
nsapp setMainMenu: menuBar
\ Add the Application menu & the quit item
appMenu = NSMenu new
quitMenuItem = NSMenuItem alloc initWithTitle: "Quit #{NSProcessInfo processInfo processName}"
action: "terminate:"
keyEquivalent: "q"
appMenu addItem: quitMenuItem
appMenuItem setSubmenu: appMenu
\ Create a window
win = NSWindow alloc initWithContentRect: #[NSZeroPoint, [300, 200]]
styleMask: NSTitledWindowMask
backing: NSBackingStoreBuffered
defer: 0
win#title = "Tranquil!"
win makeKeyAndOrderFront: nil
view = NSTextField alloc initWithFrame: (win contentView bounds)
view#stringValue = "Hey!"
win contentView addSubview: view
\ Start the app
nsapp setActivationPolicy: NSApplicationActivationPolicyRegular
nsapp activateIgnoringOtherApps:1
nsapp run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment