-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from mralexgray/scripting
Additional built-in framework search paths.
- Loading branch information
Showing
2 changed files
with
150 additions
and
32 deletions.
There are no files selected for viewing
180 changes: 148 additions & 32 deletions
180
examples/NodeCocoaHelloWorld.app/Contents/MacOS/app.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,177 @@ | ||
// // This example adapted from Matt Gallagher's "Minimalist Cocoa Programming" | ||
// // blog article: | ||
// // http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html | ||
// var $ = require('../../../../') | ||
// var EventLoop = require('../../../EventLoop') | ||
// EventLoop.initObjC($) | ||
// | ||
// $.import('Cocoa') | ||
// | ||
// var pool = $.NSAutoreleasePool('alloc')('init') | ||
// , app = $.NSApplication('sharedApplication') | ||
// , evtLoop = new EventLoop() | ||
// | ||
// app('setActivationPolicy', $.NSApplicationActivationPolicyRegular) | ||
// | ||
// var menuBar = $.NSMenu('alloc')('init') | ||
// , appMenuItem = $.NSMenuItem('alloc')('init') | ||
// | ||
// menuBar('addItem', appMenuItem) | ||
// app('setMainMenu', menuBar) | ||
// | ||
// var appMenu = $.NSMenu('alloc')('init') | ||
// , appName = $('Hello NodeJS!') | ||
// , quitTitle = $('Quit "' + appName + '"') | ||
// , quitMenuItem = $.NSMenuItem('alloc')('initWithTitle', quitTitle | ||
// ,'action', 'terminate:' | ||
// ,'keyEquivalent', $('q')) | ||
// 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) | ||
// window('setAlphaValue', 0) | ||
// window('cascadeTopLeftFromPoint', $.NSMakePoint(20,20)) | ||
// window('setTitle', appName) | ||
// window('makeKeyAndOrderFront', window) | ||
// window('center') | ||
// window('setBackgroundColor', $.NSColor('greenColor')) | ||
// window('animator')('setAlphaValue',1) | ||
// | ||
// | ||
// | ||
// | ||
// var textV = $.NSTextView('alloc')('initWithFrame', $.NSMakeRect(0,100,100,100)); | ||
// textV('setAutoresizingMask', $.NSViewWidthSizable | $.NSViewMinYMargin) | ||
// window('contentView')('addSubview', textV) | ||
// | ||
// // AppDelegate.addMethod('textDidChange:', 'v@:@', function (self, _cmd, notif) { | ||
// // $.playTrumpet() | ||
// // }) | ||
// | ||
// | ||
// // 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.addMethod('applicationWillTerminate:', 'v@:@', function (self, _cmd, notif) { | ||
// console.log('got applicationWillTerminate') | ||
// console.log(notif) | ||
// }) | ||
// AppDelegate.register() | ||
// | ||
// var delegate = AppDelegate('alloc')('init') | ||
// app('setDelegate', delegate) | ||
// | ||
// app('activateIgnoringOtherApps', true) | ||
// app('finishLaunching') | ||
// | ||
// evtLoop.start() | ||
|
||
|
||
|
||
// This example adapted from Matt Gallagher's "Minimalist Cocoa Programming" | ||
// blog article: | ||
// http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html | ||
var $ = require('../../../../') | ||
var EventLoop = require('../../../EventLoop') | ||
EventLoop.initObjC($) | ||
|
||
$.import('Cocoa') | ||
$.framework('Cocoa') | ||
// $.framework('AtoZ') | ||
// $.import('AppKit') | ||
// $.import('AtoZ') | ||
|
||
var pool = $.NSAutoreleasePool('alloc')('init') | ||
, app = $.NSApplication('sharedApplication') | ||
, evtLoop = new EventLoop() | ||
var pool = $.NSAutoreleasePool('alloc')('init'), | ||
app = $.NSApplication('sharedApplication') | ||
// atoz = $.AtoZ | ||
|
||
// var z = atoz.methods() | ||
// $.NSLog(atoz('class')('globalPalette')('stringValue')) | ||
|
||
app('setActivationPolicy', $.NSApplicationActivationPolicyRegular) | ||
|
||
var menuBar = $.NSMenu('alloc')('init') | ||
, appMenuItem = $.NSMenuItem('alloc')('init') | ||
var menuBar = $.NSMenu('new'), | ||
appMenuItem = $.NSMenuItem('new') | ||
|
||
menuBar('addItem', appMenuItem) | ||
app('setMainMenu', menuBar) | ||
|
||
var appMenu = $.NSMenu('alloc')('init') | ||
, appName = $('Hello NodeJS!') | ||
, quitTitle = $('Quit "' + appName + '"') | ||
, quitMenuItem = $.NSMenuItem('alloc')('initWithTitle', quitTitle | ||
,'action', 'terminate:' | ||
,'keyEquivalent', $('q')) | ||
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) | ||
var appMenu = $.NSMenu('new'), | ||
appName = $('Hello NodeJS!'), | ||
quitTitle = $('Quit "' + appName + '"'), | ||
quitMenuItem = $.NSMenuItem('alloc')('initWithTitle', quitTitle, 'action', 'terminate:', 'keyEquivalent', $('q')), | ||
AppDelegate = $.NSObject.extend('AppDelegate') // set up the app delegate | ||
|
||
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) | ||
window('setAlphaValue', 0) | ||
window('cascadeTopLeftFromPoint', $.NSMakePoint(20,20)) | ||
window('setTitle', appName) | ||
window('makeKeyAndOrderFront', window) | ||
window('center') | ||
window('setBackgroundColor', $.NSColor('greenColor')) | ||
window('animator')('setAlphaValue',1) | ||
|
||
var textV = $.NSTextView('alloc')('initWithFrame', $.NSMakeRect(0,100,100,100)); | ||
textV('setAutoresizingMask', $.NSViewWidthSizable | $.NSViewMinYMargin) | ||
window('contentView')('addSubview', textV) | ||
|
||
AppDelegate.addMethod('textDidChange:', 'v@:@', function (self, _cmd, notif) { | ||
$.playTrumpet() | ||
}) | ||
|
||
|
||
// 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) | ||
// console.log('got applicationDidFinishLauching') | ||
// console.log(notif) | ||
}) | ||
AppDelegate.addMethod('applicationWillTerminate:', 'v@:@', function (self, _cmd, notif) { | ||
console.log('got applicationWillTerminate') | ||
console.log(notif) | ||
}) | ||
AppDelegate.addMethod('windowDidMove:', 'v@:@', function (self, _cmd, notif) { | ||
var x = window('backgroundColor') | ||
window('setBackgroundColor', x == $.NSColor('purpleColor') ? $.NSColor('redColor') : $.NSColor('blueColor')) | ||
}) | ||
AppDelegate.addMethod('windowDidResize:', 'v@:@', function (self, _cmd, notif) { | ||
if ((notif('object')('width') % 100) < 10) { | ||
window('animator')('setBackgroundColor', $.AtoZ('globalPalette')('nextNormalObject')) | ||
// $.AZTalker('randomDicksonism') | ||
// ($.NSString('randomDicksonism')) | ||
} | ||
}) | ||
|
||
|
||
AppDelegate.register() | ||
|
||
var delegate = AppDelegate('alloc')('init') | ||
app('setDelegate', delegate) | ||
var delegate = AppDelegate('new') | ||
|
||
textV('setDelegate',delegate) | ||
app('setDelegate', delegate) | ||
window('setDelegate', delegate) | ||
app('activateIgnoringOtherApps', true) | ||
app('finishLaunching') | ||
// var azb = $.getenv('AZBUILD') | ||
// $.NSLog('%@','vageem') | ||
// console.error('vageem') | ||
// var array = $.NSMutableArray('alloc')('init') | ||
// array('addObject', $('Hello World!')) | ||
// console.log(array) | ||
|
||
// var jsString = 'a javascript String' | ||
// var nsString = $(jsString) | ||
// $.NSLog(nsString) | ||
|
||
evtLoop.start() | ||
// window('setBackgroundColor', $.NSColor('purpleColor') | ||
app('run') |
This file contains 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