Created
July 4, 2012 14:09
-
-
Save mikecsh/3047552 to your computer and use it in GitHub Desktop.
Bindings Test App
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
/* | |
* 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