|
Project Information
Members
Featured
Downloads
Wiki pages
Links
|
Source is now on Github http://github.com/parmanoir/jscocoa/tree
Talk about JSCocoa on the JSCocoa Google Group ! Check out QuickStart. Write Cocoa apps in Javascript ! JSCocoa allows calling Cocoa and C functions through JavascriptCore (Webkit's Javascript engine), using BridgeSupport and libffi to call C functions and allocate C structs. Calling Objective C is done via ObjCRuntime. JSCocoa uses parts of PyObjC.
SyntaxDot !var appName = NSWorkspace.sharedWorkspace.activeApplication.NSApplicationName InstanceNSButton.alloc.initWithFrame(NSMakeRect(0, 0, 100, 40)) // Need release
NSButton.instance({ withFrame:NSMakeRect(0, 0, 100, 40) }) // Handled by JS GCGet/Setvar title = window.title window.title = 'Hello !' Call, Split callobj.call({ withParam1:'Hello', andParam2:'World' })
obj['callWithParam1:andParam2:']('Hello', 'World')
obj.callWithParam1_andParam2('Hello', 'World' )Derivation : Child Cocoa classes written in JavascriptdefineClass('MyButton < NSButton',
{
myOutlet : 'IBOutlet'
,myAction : ['IBAction',
function (sender)
{
...
}]
})Interface BuilderJSCocoa works with NIBs, but you'll need to manually add IBOutlets and IBActions while creating your interface. If you've ever wondered why there are + and - buttons in the Identity Inspector, wonder no more ! :) |