mac applet by jxa example
eval($.NSString.stringWithContentsOfFileEncodingError($('~/Library/Script Libraries/AppletKit.js').stringByStandardizingPath.js,$.NSUTF8StringEncoding,$()).js)
ObjC.import('Cocoa')
controls = {}
UtilityWindow('AppWindow', {
setup() {
this.setFrameDisplayAnimate($.NSMakeRect(0, 0, 200, 200), false, false)
this.center
this.title = '足し算'
this.contentView.addSubview(TextField( _ => {
controls.x = _
_.frame = $.NSMakeRect(15, 140, 170, 22)
_.placeholderString = 'x'
}))
this.contentView.addSubview(TextField( _ => {
controls.y = _
_.frame = $.NSMakeRect(15, 100, 170, 22)
_.placeholderString = 'y'
}))
this.contentView.addSubview(Label( _ => {
controls.z = _
_.frame = $.NSMakeRect(15, 60, 170, 22)
}))
this.contentView.addSubview(Button( _ => {
controls.calc = _
_.frame = $.NSMakeRect(100, 10, 90, 26)
_.title = '計算'
_.target = this
_.action = 'addition:'
}))
this.defaultButtonCell = controls.calc.cell
},
addition(sender) {
let x = controls.x.intValue
let y = controls.y.intValue
controls.z.intValue = x + y
},
})
window = $.AppWindow.alloc.init
window.makeKeyAndOrderFront(this)