Re: Is NSTableView/NSOutlineView the way to go?
Re: Is NSTableView/NSOutlineView the way to go?
- Subject: Re: Is NSTableView/NSOutlineView the way to go?
- From: Mark Dawson <email@hidden>
- Date: Thu, 23 Jun 2005 14:56:46 -0700
If it helps any, here's the code I use to put checkboxes in the rows of a table. I do this in the -awakeFromNib method:
NSButtonCell *checkboxCell =
[[[NSButtonCell alloc] initTextCell:@""] autorelease];
[checkboxCell setButtonType:NSSwitchButton];
[[_frameworksTable
tableColumnWithIdentifier:_AKCheckboxesColumnID]
setDataCell:checkboxCell];
A few questions:
(1) _frameworksTable is a private (Apple private) instance variable? Is this different than the outlet I have hooked up to the NSTableView?
(2) What is '_AKCheckboxesColumnID"? I assume I could also use the column title (
NSLocalizedStringFromTable(@"ColumnTitle"…)
(3) What is the id type returned for tableView: objectValueForTableColumn:row: -- a BOOL?
I think you'd also have to manage the "radioness" of the button cells yourself -- i.e., when the user turns one on, turn off the one that was previously turned on. When the cells are in an NSMatrix, you get this for free, but NSTableView uses one cell instance to draw all the cells in a column. So I think you're going to have to implement -tableView:willDisplayCell:forTableColumn:row:.
So you're saying I'd do something like:
<x-tad-bigger>-(void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(</x-tad-bigger><x-tad-bigger>NSTableColumn</x-tad-bigger><x-tad-bigger> *)aTableColumn row:(int)rowIndex</x-tad-bigger>
{
if ([[<x-tad-bigger>aTableColumn</x-tad-bigger> identifier] isEqualToString:@"RadioButtonColumnName"])
{
BOOL isActive = [self isActiveRow:<x-tad-bigger>rowIndex</x-tad-bigger> inTable:aTableView];
[aCell <x-tad-bigger>setState: </x-tad-bigger>(isActive ? NSOnState : NSOffState);
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden