Re: column of buttons in NSTableView - a solution?
Re: column of buttons in NSTableView - a solution?
- Subject: Re: column of buttons in NSTableView - a solution?
- From: Matt Neuburg <email@hidden>
- Date: Fri, 03 Nov 2006 10:35:32 -0800
- Thread-topic: column of buttons in NSTableView - a solution?
On Thu, 2 Nov 2006 21:27:44 -0800, Boyd Collier
<email@hidden> said:
>I didn't do a good job of asking the question, which really had to do
>with whether the table's data source used to establish a button in
>every row of a column that is to contain the buttons also had to hold
>an array of NSButtonCells, or whether a simpler and more efficient
>way of keeping track of the buttons' states could be used. After
>thinking it through, I realized that the answer is yes, and I
>implemented a way to do this simply by allocating an array of ints
>which are set either to 0 or 1, depending on whether the switch in
>the row of the table corresponding to the int in the array should be
>off or on. Then in objectValueForTableColumn: row: the value of the
>particular int that's keeping track of the state of the switch is
>determined and a single, autoreleased instance of NSButtonCell is
>allocated and used as the return value of this method. In the method
>setObjectValue: forTableColumn: row: I check the state of the switch
>in the column and set the int in the array of ints to the appropriate
>value.
It's way overkill to return an NSButtonCell from
objectValueForTableColumn:row:. In Interface Builder, just set the column to
be a button column (drag a button cell onto the header of the column). In
your code, just return an NSNumber (0 or 1) from
objectValueForTableColumn:row: to indicate the state. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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