Re: Disabling a particular NSButtonCell in NSTableView
Re: Disabling a particular NSButtonCell in NSTableView
- Subject: Re: Disabling a particular NSButtonCell in NSTableView
- From: Felix Franz <email@hidden>
- Date: Tue, 12 Jun 2007 18:43:20 +0200
On Jun 12, 2007, at 6:20 PM, K. Darcy Otto wrote:
I've used Interface Builder to set up an NSTableView, and in one
column I have a column of NSButtonCell buttons. I want to disable
the button at a certain row, while leaving the rest of the buttons
enabled. My questions are two:
(i) how do I refer to a particular button at some arbitrary row?
(i) what message do I send the button so just that button becomes
disabled?
You have to set a delegate for the NSTableView and implement the
tableView:willDisplayCell:forTableColumn:row:-method (described in
the NSTableView-documentation).
This method is called before a particular cell is drawn. Something
like (typed in Mail:)
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if (![aTableColumn isEqual: buttonColumn])
return; // do nothing for the other columns
[aCell setEnabled: rowIndex != rowIndexToDisable]; // where
rowIndexToDisable would be the row index with the disabled button
}
HTH,
felix
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden