Skip to content

Instantly share code, notes, and snippets.

@mikecsh
Created July 4, 2012 14:09
Show Gist options
  • Save mikecsh/3047552 to your computer and use it in GitHub Desktop.
Save mikecsh/3047552 to your computer and use it in GitHub Desktop.
Bindings Test App
/*
* AppController.j
* DatePickerTest
*
* Created by You on July 3, 2012.
* Copyright 2012, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/AppKit.j>
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var claim = [TestClaim new];
var nameField = [CPTextField textFieldWithStringValue:@"Name" placeholder:@"-" width:100];
[contentView addSubview:nameField];
[nameField bind:@"objectValue" toObject:claim withKeyPath:@"name" options:nil];
[claim setName:@"Miles"];
[theWindow orderFront:self];
}
@end
@implementation TestClaim : CPObject
{
CPString name @accessors;
}
- (void)setName:(id)obj
{
[self willChangeValueForKey:@"name"];
name = obj;
[self didChangeValueForKey:@"name"];
// Why does this not fire when we edit the text field?
console.log("The name was changed to = ", name);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment