Re: Embedding a Check Box in an NSTableView
Re: Embedding a Check Box in an NSTableView
- Subject: Re: Embedding a Check Box in an NSTableView
- From: "M. Uli Kusterer" <email@hidden>
- Date: Fri, 2 Apr 2004 14:39:18 +0200
At 22:37 Uhr -0500 01.04.2004, Bruce Truax wrote:
I have a table view where one column is displaying a boolean value. Is it
possible to put a check box in this column to display and allow changing the
state of the boolean value?
Yes. You have to set the dataCell of the NSTableColumn. In
10.3-style NIB files, you can do this by simply dragging one of the
cell images (the small controls in boxes) from the IB palette onto
your table column's header, which gives you a little triangle
representing the data cell.
You can also do it manually (in any system version) in e.g. your
awakeFromNib method by creating an NSButtonCell, set its style to
NSSwitchButton or NSRadioButton and using setDataCell: on the column.
Also make sure the column is marked as editable, and that you're
implementing the tableView:takeObjectValue:forTableColumn:row: data
source method. It will get an NSNumber with YES or NO as its value.
In another case I also need to display a boolean value but in this case it
it mutually exclusive. In other words, for all of the items in the table,
only one true value is allowed and the rest must be false. In this case it
would be ideal if I could use an array of radio buttons. Is this possible?
Note that, while NSTableView will automatically toggle on/off
checkbox cells, and will also automatically toggle *on* radio button
cells, it will not deactivate the other radio buttons. You will have
to do that yourself by changing values in your data source and
calling setNeedsDisplay: or reloadData to make them redraw.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.