Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created August 13, 2012 07:33
Show Gist options
  • Save fjolnir/3337813 to your computer and use it in GitHub Desktop.
Save fjolnir/3337813 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
quitMenuItem = NSMenuItem alloc initWithTitle: "Quit #{NSProcessInfo processInfo processName}"
action: "terminate:"
keyEquivalent: "q"
appMenu = NSMenu new;
addItem: quitMenuItem;
self
appMenuItem setSubmenu: appMenu
\ Create a window
win = NSWindow alloc initWithContentRect: [NSZeroPoint, [300, 200]]
styleMask: (NSTitledWindowMask bitOr: NSResizableWindowMask)
backing: NSBackingStoreBuffered
defer: no;
setTitle: "Tranquil!";
makeKeyAndOrderFront: nil;
self
\ Create a little view
#TestView < NSView {
- drawRect: dirtyRect {
NSColor cyanColor set
(NSBezierPath bezierPathWithRect: dirtyRect) fill
}
}
view = TestView new; setFrame: (win contentView bounds); self
win#contentView = view
\ Start the app
nsapp setActivationPolicy: NSApplicationActivationPolicyRegular
nsapp activateIgnoringOtherApps: yes
nsapp run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment