
Signature
/los "I was a teenage net-random"
------------------------------------------------------------------------
Opinions expressed here are mine and not necessarily those of my employer!
------------------------------------------------------------------------
> I've used both sliders and level indicators but when I try to use them
> in a table/outline view, I always get zero for the value; Initially I
[quoted text clipped - 16 lines]
> - (IBAction)cellLevel:(id)sender
> {
What kind of object do you believe sender is when cellLevel: is invoked?
I'm guessing you think it's an NSTableView, but I'm betting it's an
NSLevelIndicatorCell. You note that value is zero;I'd bet col is, too,
and tableColumn and cell are nil. And you're probably getting a good
spew to the console as well.
> int col = [sender clickedColumn];
> id tableColumn = [[sender tableColumns] objectAtIndex:col];
[quoted text clipped - 13 lines]
> p.s. if there are examples of either tableview cell usages, please let
> me know that too, thanks.
I suspect at least part of what you're running into is that the cells of
a table view aren't there to store data. They provide a representation
of the data that's there and may provide an interface by which the user
can change the data, but actually storing the data - providing it when
the tableview asks for it, and updating it when the tableview tells you
- is up to you. Querying the value of an nstablecolumn's cell at any
random time is, I think, not a sensible or reliable action.
slashlos - 27 Mar 2007 01:09 GMT
>> I've used both sliders and level indicators but when I try to use them
>> in a table/outline view, I always get zero for the value; Initially I
[quoted text clipped - 22 lines]
> and tableColumn and cell are nil. And you're probably getting a good
> spew to the console as well.
debugger says this about the cellLevel invocation:
sender isa NSOutlineView
col is '3'; which is right
tableColumn isa the class of my sub-class'd object
cell isa NSLevelIndicatorCell
there's nothing on the console to indicate an error; I have a bunch of
NSLog output that I do see but nothing else
>> int col = [sender clickedColumn];
>> id tableColumn = [[sender tableColumns] objectAtIndex:col];
[quoted text clipped - 21 lines]
> - is up to you. Querying the value of an nstablecolumn's cell at any
> random time is, I think, not a sensible or reliable action.
Yes, I realize my outline/table views data source could be called to
supply values for the outline/table view, but shouldn't the action be
called first? The initial value for the control is set right, but when
I go to modify it, my action is called but the value is zero. After
which I would call the item objects' 'set' routine [or I could call the
outline/table view's datasource to set back the value].
I would expect the action to get called and have the control's value for
me to send it back into the item. A similar setup for button cell works
just fine, so I presume it's something specific to the slider/level that
I'm doing wrong, but what?

Signature
/los "I was a teenage net-random"
------------------------------------------------------------------------
Opinions expressed here are mine and not necessarily those of my employer!
------------------------------------------------------------------------
> I've used both sliders and level indicators but when I try to use them
> in a table/outline view, I always get zero for the value; Initially I
> set them up as this in a subclass of NSTableColumn:
[snip]
> then in the class for the item (the action routine) I do this:
>
> - (IBAction)cellLevel:(id)sender
> {
[snip]
The proper way to find out about changed values in a table/outline view is
to implement the appropriate method in your data source. For NSTableView
that method is:
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn row:(int)row;
NSOutlineView has a similar one. The class of the object will depend on
the control that's being used; for a level indicator I would expect it to
be an NSNumber, but you can verify that in the debugger.

Signature
Michael Ash
Rogue Amoeba Software
slashlos - 27 Mar 2007 13:16 GMT
>> I've used both sliders and level indicators but when I try to use them
>> in a table/outline view, I always get zero for the value; Initially I
[quoted text clipped - 16 lines]
> the control that's being used; for a level indicator I would expect it to
> be an NSNumber, but you can verify that in the debugger.
While I understand, I'm confused; is the control's action routine solely
to set its value to what the outline/table views datasource has or maybe
no? It almost seems like it's not needed?

Signature
/los "I was a teenage net-random"
------------------------------------------------------------------------
Opinions expressed here are mine and not necessarily those of my employer!
------------------------------------------------------------------------
Michael Ash - 27 Mar 2007 14:45 GMT
>> The proper way to find out about changed values in a table/outline view is
>> to implement the appropriate method in your data source. For NSTableView
[quoted text clipped - 10 lines]
> to set its value to what the outline/table views datasource has or maybe
> no? It almost seems like it's not needed?
You're not dealing with a control here, you're dealing with a cell. In the
case of a table/outline view, the cell's target/action capability is not
used in the normal way. It might be used behind the scenes so that the
table/outline view itself can find out about changes, but in any case it's
not for client code.

Signature
Michael Ash
Rogue Amoeba Software
slashlos - 27 Mar 2007 17:01 GMT
>>> The proper way to find out about changed values in a table/outline view is
>>> to implement the appropriate method in your data source. For NSTableView
[quoted text clipped - 15 lines]
> table/outline view itself can find out about changes, but in any case it's
> not for client code.
thanks; got it sorted out now.

Signature
/los "I was a teenage net-random"
------------------------------------------------------------------------
Opinions expressed here are mine and not necessarily those of my employer!
------------------------------------------------------------------------