On Apr 20, 2011, at 00:25, Ben Golding wrote:

> On 20/04/2011, at 15:41, Ken Thomases wrote:
> 
>> On Apr 19, 2011, at 8:46 PM, Ben Golding wrote:
>> 
>>> I should have been more specific.  What I have looks like:
>>> 
>>> popupButton.content -(Transformer)-> [arrayController].arrangedObjects
>>> popupButton.selectedIndex --> [arrayController].selectionIndex
>>> 
>>> I have also tried:
>>> 
>>> popupButton.contentValues -(Transformer)-> [arrayController].arrangedObjects
>>> popupButton.selectedIndex --> [arrayController].selectionIndex
>> 

Ugh. You made me look into it, so I had to suffer along with you.

I tried a test project, and figured out the answer. We actually had the answer 
all along but didn't pay enough attention to the evidence.

We're all wrong in thinking that the popup button behaves like a table column. 
A table column *looks* like it's bound directly to an array controller's 
arrangedObjects, but it isn't. Instead, the table chooses an object from 
arrangedObjects, and the table column via its binding picks out a property from 
*that* object.

This isn't what happens with popup buttons. Its content bindings *are* bindings 
to the array controller. That is, "content" or "contentValues" *is* an array, 
and that's what gets passed to the value transformer. The handling of the array 
as individual menu item strings happens inside the popup button implementation 
(later), and has nothing really to do with the binding.

Your value transformer, if you insist on doing it that way, should be coded to 
expect this, and should transform an entire array of strings, not single 
strings.

(And since your original array is an array of strings, I don't think you don't 
need to do anything with the "contentObjects" or "contentValues" bindings of 
the popup button.)

Remember that the original problem was that your transformer got a proxy for 
the array controller('s content) as a whole, not for individual array elements. 
That was the evidence we were ignoring.

> I'm really close to going back to the "old" way which disappoints me.

I still maintain that any time spent is getting NSPopUpButton content bindings 
to work is wasted. Or masochism. You're not getting new, you're getting hurt. :)


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to