Re: Conditionally adding NSButtonCell to a column of NSTableview and allowing button cell to take action even if the corresponding row is not allowed to be selected
Re: Conditionally adding NSButtonCell to a column of NSTableview and allowing button cell to take action even if the corresponding row is not allowed to be selected
- Subject: Re: Conditionally adding NSButtonCell to a column of NSTableview and allowing button cell to take action even if the corresponding row is not allowed to be selected
- From: Quincey Morris <email@hidden>
- Date: Mon, 28 Feb 2011 22:51:49 -0800
On Feb 28, 2011, at 22:36, Deepa wrote:
> I am already displaying a NSTableview with one column. The tableview is disabled and I do not allow the user to select any row of the tableview. In each row of this column I display a NSTextFieldCell.
>
> Now, I want to add one more column that displays NSButtonCell in a row when some condition on that row is satisfied. User should be able to click on this button and send some action.
>
> If I disable the tableview or if I do not allow the user to select the row of a tableview, the button cell does not take any action. How do I achieve this?
You should be able to achieve this using the 'tableView:shouldTrackCell:forTableColumn:row:' delegate method of NSTableView:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSTableViewDelegate_Protocol/Reference/Reference.html
You may have to leave the table enabled, though, and use other means to prevent row selection and cell editing from working.
> Also, what is the best way to conditionally add a cell to a row?
Probably using another delegate method, 'tableView:dataCellForTableColumn:row:' (in the same document).
Also, although it's not documented and so perhaps can't be relied upon, but I've found that you can return 'nil' from this method to use the normal cell for the row/column. That saves a bit of work if you only need to supply a cell for a few special rows.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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