Created
August 13, 2012 07:33
-
-
Save fjolnir/3337813 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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