Re: NSButtonCell & tableView (s)
Re: NSButtonCell & tableView (s)
- Subject: Re: NSButtonCell & tableView (s)
- From: Rakesh Pandey <email@hidden>
- Date: Thu, 23 Jan 2003 13:50:50 +0530
Implement the - (void)tableView:(NSTableView *)aTableView
willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex method where you can set the button cell and change
the title.
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
//set the title and state of button here......
}
On Thursday, January 23, 2003, at 01:25 PM, Chad Armstrong wrote:
>
I'm trying to create an app which has an NSTableView with only one
>
column in it. In each row/cell, I want an switch button with a string
>
of words after it. Before I started mucking around with the
>
NSButtonCell and such, I had the app with just strings (instead of
>
NsButtonCells) working just fine. I haven't found much cohesive code
>
to sort out my problems. Here is some of my example code, and I'm
>
hoping someone can identify what is going wrong, or what I need to
>
add. I want to be able to change both the switch box and the string
>
if possible.
>
>
- (void) awakeFromNib
>
{
>
>
NSButtonCell *buttonCell = [[[NSButtonCell alloc] init]
>
autorelease];
>
NSTableColumn *buttonColumn = [table
>
tableColumnWithIdentifier:@"To Do"];
>
>
records = [[NSMutableArray alloc] init];
>
>
[buttonCell setButtonType:NSSwitchButton];
>
[buttonCell setImagePosition:NSImageLeft];
>
[buttonCell setTitle:@""];
>
[buttonColumn setDataCell:buttonCell];
>
}
>
>
>
>
- (id)tableView:(NSTableView*)table
>
objectValueForTableColumn:(NSTableColumn*)col row:(int)rowIndex
>
{
>
>
// return [records objectAtIndex:rowIndex];
>
>
id result = nil;
>
NSDictionary *dict = [records objectAtIndex:rowIndex];
>
>
// these didn't agree with the compiler
>
// id stringValue = [dict objectForKey:[col identifier]];
>
//id stringValue = [super tableView:inTableView
>
objectValueForTableColumn:inTableColumn row:inRowIndex];
>
>
NSString *identifier = [col identifier];
>
>
>
>
if ([identifier isEqualToString:@"To Do"]) // it doesn't seem to
>
get in here...
>
{
>
result = [records objectAtIndex:rowIndex];
>
//result = [NSNumber numberWithInt:[stringValue intValue]];
>
// result = @"foo";
>
NSLog(@"Saw the To Do");
>
}
>
else
>
{
>
result = [records objectAtIndex:rowIndex];
>
NSLog(@"NOT in To Do");
>
}
>
>
return result;
>
>
}
>
>
>
// really not quite sure how to go about doing this one...
>
- (void)tableView:(NSTableView*)table
>
willDisplayCell:(id)aCell
>
forTableColumn:(NSTableColumn*)col
>
row:(int)rowIndex
>
{
>
// old code before the NSButtonCell was added
>
// [records replaceObjectAtIndex:rowIndex withObject:aCell];
>
>
//NSMutableDictionary *dict = [records objectAtIndex:rowIndex];
>
//[dict setObject:aCell forKey:[col identifier]];
>
>
// [aCell setButtonType: NSSwitchButton];
>
[aCell setAllowsMixedState:YES];
>
[aCell setState:NO];
>
// [aCell setTitle: [itemField stringValue]];
>
}
>
>
>
>
Regards,
>
>
Chad Armstrong
>
_______________________________________________
>
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.
>
Rakesh Pandey
------------------------------------------------------------------------
--------
Windows) 98 (n) - 32-bit extensions and graphical shell
for a 16-bit patch to an 8-bit operating system
originally coded for a 4-bit microprocessor
written by a 2-bit company
that can't stand 1 bit of competition.
_______________________________________________
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.