Skip to content

Instantly share code, notes, and snippets.

@TravisSpangle
Created November 15, 2011 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TravisSpangle/1368716 to your computer and use it in GitHub Desktop.
Save TravisSpangle/1368716 to your computer and use it in GitHub Desktop.
Table Delegate methods seem to fire with inconsistant events. Use the below AppController in Tests/Manual/TableTests/BorderTableTests to demonstrate the problem.
/*
* AppController.j
* TableCibTest
*
* Created by Francisco Tolmasky on July 5, 2009.
* Copyright 2009, 280 North, Inc. All rights reserved.
*/
@import <Foundation/CPObject.j>
CPLogRegister(CPLogConsole);
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
CPScrollView theScrollView;
CPTableView theTableView;
CPPopupButton theBorderTypePopup;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
}
- (void)awakeFromCib
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
[theWindow setBackgroundColor:[CPColor colorWithHexString:@"f3f4f5"]];
[theBorderTypePopup selectItemWithTag:[theScrollView borderType]];
[theTableView setDelegate:self];
}
- (int)numberOfRowsInTableView:(CPTableView)tableView
{
return 10;
}
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
{
return String((row + 1) * [[tableColumn identifier] intValue]);
}
// Actions
- (void)setBorder:(id)sender
{
var type = [[sender selectedItem] tag];
console.log('type=%d', type);
[theScrollView setBorderType:type];
}
/*
Table Delegates
*/
-(void)tableViewSelectionDidChange:(CPNotification)aNotification
{
//this fires with mouse clicks
//this fires with mouse clicks with arrow-key changes
console.log("Selection did Change");
}
-(void)tableViewSelectionIsChanging:(CPNotification)aNotification
{
//this fires with mouse clicks
//does not fire with arrow-key changes
console.log("Selection will Change");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment