Checkboxes (Buttons) in NSTables
Checkboxes (Buttons) in NSTables
- Subject: Checkboxes (Buttons) in NSTables
- From: Sean Peisert <email@hidden>
- Date: Thu, 13 Mar 2003 16:14:32 -0800
I'm having a heck of a time inserting checkboxes into an NSTable
element despite having the code and NIB that I think are correct.
The NSTable element have this class as a datasource and containst the
columns "enabled" and "tool". When I run this, I get 'a', b', 'c',
'd' in the "tool" column, as expected, but the "enabled" column which
should have the checkboxes displays nothing. What am I doing wrong
here? Is this the right code? (Largely taken from an earlier
developer list:
http://cocoa.mamasam.com/COCOADEV/2002/04/1/31115.php)
Thanks,
Sean
#import "ToolController.h"
@implementation ToolController
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
return 4;
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
tools = [NSArray arrayWithObjects: @"a", @"b", @"c", @"d", nil];
NSString *identifier = [tableColumn identifier];
if ([identifier isEqual:@"tool"]){
return [tools objectAtIndex:row];
} else {
return NO;
//return [NSNumber numberWithBool: NO];
//return nil;
}
}
- (void) awakeFromNib {
NSTableColumn *tColumn;
id tPrototypeCell;
tPrototypeCell = [[[NSButtonCell alloc] initTextCell: @""] autorelease];
[tPrototypeCell setButtonType:NSSwitchButton];
[tPrototypeCell setImagePosition:NSImageOnly];
[tPrototypeCell setControlSize:NSSmallControlSize];
tColumn=[tableView tableColumnWithIdentifier:@"enabled"];
[tColumn setDataCell:tPrototypeCell];
[tableView setDelegate: self];
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.