Forked from TooTallNate/cocoa-hello-world2.js
Created
September 8, 2011 18:33
Revisions
-
TooTallNate revised this gist
Sep 8, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // This example adapted from Matt Gallagher's "Minimalist Cocoa Programming" // blog article: // http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html var $ = require('NodObjC') $.import('Cocoa') -
TooTallNate created this gist
Sep 8, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ // This example adapted from Matt Gallagher's "Minimalist Cocoa Programming" // blog article: // http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html var $ = require('./NodObjC') $.import('Cocoa') var pool = $.NSAutoreleasePool('alloc')('init') , app = $.NSApplication('sharedApplication') app('setActivationPolicy', $.NSApplicationActivationPolicyRegular) var menuBar = $.NSMenu('alloc')('init')('autorelease') , appMenuItem = $.NSMenuItem('alloc')('init')('autorelease') menuBar('addItem', appMenuItem) app('setMainMenu', menuBar) var appMenu = $.NSMenu('alloc')('init')('autorelease') , appName = $._('Hello NodeJS!') , quitTitle = $._('Quit ')('stringByAppendingString', appName) , quitMenuItem = $.NSMenuItem('alloc')('initWithTitle', quitTitle ,'action', 'terminate:' ,'keyEquivalent', $._('q'))('autorelease') appMenu('addItem', quitMenuItem) appMenuItem('setSubmenu', appMenu) var styleMask = $.NSTitledWindowMask | $.NSResizableWindowMask | $.NSClosableWindowMask var window = $.NSWindow('alloc')('initWithContentRect', $.NSMakeRect(0,0,200,200) ,'styleMask', styleMask ,'backing', $.NSBackingStoreBuffered ,'defer', false)('autorelease') window('cascadeTopLeftFromPoint', $.NSMakePoint(20,20)) window('setTitle', appName) window('makeKeyAndOrderFront', window) // set up the app delegate var AppDelegate = $.NSObject.extend('AppDelegate') AppDelegate.addMethod('applicationDidFinishLaunching:', 'v@:@', function (self, _cmd, notif) { console.log('got applicationDidFinishLauching') console.log(notif) }) AppDelegate.register() var delegate = AppDelegate('alloc')('init') app('setDelegate', delegate) app('activateIgnoringOtherApps', true) app('run')