Re: Select checkbox in NSTableView
Re: Select checkbox in NSTableView
- Subject: Re: Select checkbox in NSTableView
- From: Ryan Britton <email@hidden>
- Date: Fri, 11 Nov 2005 13:54:52 -0800
You need to set the state on the actual data as provided by the
datasource, then do a reload on the table to refresh it. Setting the
checkbox will have no effect since the object returned is the
prototype cell and not actually guaranteed to be tied to any
particular row.
Something like this would work if you're using an NSArrayController
to provide data to the table. Here I have an array of mutable
dictionaries.
e = [[arrayController content] objectEnumerator];
while (entry = [e nextObject])
{
if (targetState == NSOnState)
{
[entry setObject:[NSNumber numberWithBool:YES] forKey:@"on"];
}
else
{
[entry setObject:[NSNumber numberWithBool:NO] forKey:@"on"];
}
}
On Nov 11, 2005, at 1:41 PM, Richard Salvatierra wrote:
I have an NSTableView of 4 columns. The first of which is a checkbox.
id checkboxCell = [[NSButtonCell alloc] initTextCell: @""];
[checkboxCell setButtonType: NSSwitchButton];
[[myTableView tableColumnWithIdentifier: @"checkbox"] setDataCell:
checkboxCell];
I want to add a button that checks all of the checkboxes for each
row. I tried:
int theIndex;
int rowCount = [clientList numberOfRows];
for(theIndex=0; theIndex < rowCount; theIndex++){
NSButtonCell *aCell = [clientList
tableColumnWithIdentifier:@"checkbox"] dataCellForRow:theIndex];
[aCell setState:NSOnState];
NSLog(@"%@", [aCell state]);
}
The NSLog print out of each aCell is the same object. Is this the
prototype of the tableColumn. How do I get each columns checkbox
to set the state?
_______________________________________________
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
_______________________________________________
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