I have a NSPopUpButton that is driven by bindings. I establish (programmatically) a binding between the NSPopUpButtom instance's "selectedTag" property and an NSTreeController that contains objects that have a property that should correspond with the available tag values. This does not seem to work. It appears that the binding is instead working with the popup button's index value. Symptoms and circumstance:

1) I changed the binding for the popup button's contentValues to refer to the tag property of the bound collection (rather than the title), and sure enough the proper tag values are displayed, so the menu items do have tag values.

2) When I change the popup button selection, the value in the object bound to the "selectedTag" is changed -- problem is: the value that is set is the index value, not the tag value.

The code...

First, what works: I drive the content and contentValues from an object that I construct which is an indexed accessor KVC (read-only) compliant with a backing store array of NSMenuItem items. When I initialize the collection, the menu items are initialized with a title. I also set the tag property. The bindings for these to the NSPopUpButton instance is done programmatically:

        [twitterUpdateFrequencyPopupButton bind:@"content"
                                        toObject:updateItems
                                        withKeyPath:@"UpdateFrequencyMenuItems"
                                        options:nil];
        [twitterUpdateFrequencyPopupButton bind:@"contentValues"
                                        toObject:updateItems
                                        
withKeyPath:@"UpdateFrequencyMenuItems.tag"
                                        options:nil];

"updateItems" is the ordered collection of NSMenuItems; its indexed accessor property is "UpdateFrequencyMenuItems"

Here's what doesn't work, the binding for the selected tag value:

        [twitterUpdateFrequencyPopupButton bind:@"selectedTag"
                                        toObject:twitterAccountsArrayController
                                        withKeyPath:@"selection.frequency"
                                        options:nil];


"twitterAccountsArrayController" is an NSArrayController. The objects it manages have a "frequency" property.

When this is run, I receive no messages in the console about anything bad or wrong.

I've tried searching the usual places and with Marc Liyange's Mac Developer Search Engine for matters related to NSPopUpButton and selectedTag, but haven't found anything germane. So I post here.







_______________________________________________

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