Re: NSTableColumn unbindable when NSSegmentedCell is used?
Re: NSTableColumn unbindable when NSSegmentedCell is used?
- Subject: Re: NSTableColumn unbindable when NSSegmentedCell is used?
- From: "Mike Laurence" <email@hidden>
- Date: Fri, 31 Oct 2008 00:44:08 -0500
Ahhh... it all begins to make sense. I suppose it would be difficult to have
a binding that could automatically determine what quantity of buttons and
labels you desired in your content item. But the whole purpose of my app is
to have dynamic button labels and colors, so...
Fortunately, your suggestion of a delegate method worked perfectly! I routed
the table view's delegate outlet to my content array controller and added
the following method to the controller:
def tableView_willDisplayCell_forTableColumn_row(tableView, cell, column,
row)
if column.identifier == 'segments'
cell.setup arrangedObjects.objectAtIndex(row).segments
end
end
Beautiful. Thank you for the advice!
Regards,
Mike
On Fri, Oct 31, 2008 at 12:05 AM, Quincey Morris <
email@hidden> wrote:
> On Oct 30, 2008, at 20:38, Mike Laurence wrote:
>
> Thanks for the suggestion, but I need to be able to set the contents of
>> the
>> cell (e.g., the labels of the different buttons) before the selected
>> index/tag/label is of any use.
>>
>> With a data source, the cell received a 'setObjectValue' call with an
>> array
>> of items, each corresponding to a different button, so it was easy to
>> iterate over said array and assign the buttons in one quick gesture.
>>
>> With bindings, every other type of cell (?) has a 'value' binding which
>> corresponds to the same setObjectValue method, which is called
>> automatically
>> when the data is populated into my underlying array. But NSSegmentedCell
>> lacks it completely - perhaps I have to subclass it and add my own
>> bindings?
>> I haven't done that before, but I guess I'll give it a shot.
>>
>> If anyone has had any experience with the NSSegmentedCell in a bindings
>> fashion, please let me know what steps you took to get it working.
>>
>
> There's no requirement that a bindable object have a "Value" binding. It's
> just a convention that most things having a single value use.
>
> NSSegmentedCell happens to have 3 bindings: "Selected Index", "Selected
> Label" and "Selected Tag". You can only bind one of them, and it determines
> which of 3 possible ways of identifying the current segment your application
> chooses to use (index, name or label, tag).
>
> You enter the segment labels in IB itself. Click your way down to the table
> column (click to select the scroll view, click again to select the table,
> click once more to select the column). Then click *again* on the cell at the
> top of the column to select it, then go to the Attributes tab of IB's
> inspector window. There's a popup menu there that allows you to go to any
> segment, and a text field you can use to enter its label. (Similarly, on the
> Size tab, there's a popup menu for choosing which segment you want to set
> the size for.)
>
> There appear to be no bindings for the segment labels. I would take that as
> a hint that the segment labels are intended (as a UI matter) to remain the
> same, and not vary from row to row. (However, if you needed to do that, I
> guess you could use a table view delegate to change the NSSegmentCell before
> it draws.)
>
> Note that, say, check box cells work analogously. They have a binding
> (called "Value") which determines whether they are on or off. However the
> text that appears beside the checkbox is entered in IB and has no available
> binding.
>
> HTH
>
> _______________________________________________
>
> 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
>
_______________________________________________
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