Files
cappuccino/Tests/Manual/TableTest/TableBindings/AppController.j
T
cacaodev db8f2fdf75 Added support for CPTableView content binding, generally used with view-based tables.
Grouped the 3 ways to set objectValue on a dataview (content binding, column value binding or regular delegate method) under one main method: _setObjectValueFortableColumn:row:ForView:
    Also fixed a bug where the dragging rows didn't have their bindings applied. Columns and row dragging are now using the previous method for setting data view objectValue.

    Updated TableBindings example: table with content binding vs. columns with value binding.
2012-05-16 15:57:26 +02:00

69 lines
1.8 KiB
Plaintext

/*
* AppController.j
* TableBindings
*
* Created by You on January 16, 2011.
* Copyright 2011, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
@outlet CPTextField locationField;
@outlet CPTextField lengthField;
@outlet CPPopUpButton KeyPathPopup;
CPArray rows @accessors;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
rows = [CPArray new];
var path = [[CPBundle mainBundle] pathForResource:@"rows.plist"],
request = [CPURLRequest requestWithURL:path],
connection = [CPURLConnection connectionWithRequest:request delegate:self];
[theWindow setFullBridge:YES];
}
- (void)connection:(CPURLConnection)connection didReceiveData:(CPString)dataString
{
if (!dataString)
return;
var data = [[CPData alloc] initWithRawString:dataString],
theRows = [CPPropertyListSerialization propertyListFromData:data format:CPPropertyListXMLFormat_v1_0];
[self setRows:theRows];
}
- (IBAction)updateOrReloadContent:(id)sender
{
var range = CPMakeRange([locationField intValue], [lengthField intValue]),
indexes = [CPIndexSet indexSetWithIndexesInRange:range],
keyPath = [KeyPathPopup titleOfSelectedItem];
var value = String.fromCharCode(97 + Math.round(Math.random() * 26));
if ([sender tag] == 1000)
[[rows objectsAtIndexes:indexes] setValue:value forKey:keyPath];
else
{
var rowsCopy = [rows copy];
[[rowsCopy objectsAtIndexes:indexes] setValue:value forKey:keyPath];
[self setRows:rowsCopy];
}
}
@end