Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added simple table view delegate example
- Loading branch information
1 parent
35d4f35
commit 5f68edf
Showing
340 changed files
with
73,310 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,71 @@ | |||
/* | |||
* AppController.j | |||
* simple-tableview | |||
* | |||
* Created by Stefan Huber on June 5, 2010. | |||
* Copyright 2010, MSNexploder (at) gmail.com All rights reserved. | |||
*/ | |||
|
|||
@import <Foundation/CPObject.j> | |||
|
|||
@implementation AppController : CPObject | |||
{ | |||
CPArray _tableContent; | |||
} | |||
|
|||
- (id)init | |||
{ | |||
if (self = [super init]) { | |||
_tableContent = [[CPArray alloc] init]; | |||
[_tableContent addObject:@"Cappuccino"]; | |||
[_tableContent addObject:@"Awesome"]; | |||
[_tableContent addObject:@"Stuff"]; | |||
} | |||
return self; | |||
} | |||
|
|||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |||
{ | |||
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask]; | |||
var contentView = [theWindow contentView]; | |||
|
|||
var scrollView = [[CPScrollView alloc] initWithFrame:[contentView bounds]]; | |||
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |||
|
|||
var tableView = [[CPTableView alloc] initWithFrame:[scrollView bounds]]; | |||
[tableView setDataSource:self]; | |||
[tableView setDelegate:self]; | |||
|
|||
var column = [[CPTableColumn alloc] initWithIdentifier:@"Stuff"]; | |||
[[column headerView] setStringValue:@"Stuff"]; | |||
[tableView addTableColumn:column]; | |||
|
|||
[scrollView setDocumentView:tableView]; | |||
[contentView addSubview:scrollView]; | |||
|
|||
[theWindow orderFront:self]; | |||
} | |||
|
|||
- (int)numberOfRowsInTableView:(CPTableView)aTableView | |||
{ | |||
return [_tableContent count]; | |||
} | |||
|
|||
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aTableColumn row:(int)aRow | |||
{ | |||
return [_tableContent objectAtIndex:aRow]; | |||
} | |||
|
|||
- (void)tableViewSelectionDidChange:(CPNotification)aNotification | |||
{ | |||
row = [[[aNotification object] selectedRowIndexes] firstIndex]; | |||
// console.info(row); | |||
if (row == -1) { | |||
console.info(@"Nothing selected"); | |||
} | |||
else { | |||
console.info([CPString stringWithFormat:@"selected: %@", [_tableContent objectAtIndex:row]]); | |||
} | |||
} | |||
|
|||
@end |
Oops, something went wrong.