bindings with two interdependent NSPopupButtons
bindings with two interdependent NSPopupButtons
- Subject: bindings with two interdependent NSPopupButtons
- From: "Justin R. Miller" <email@hidden>
- Date: Thu, 28 Jun 2007 01:11:44 -0400
First, perhaps the subject is a bit misleading -- I understand that
views can only be bound to controllers, not to each other. What I'm
trying to do is make a property of one button contingent on the
selection in the other button.
I have two NSPopupButtons, each bound to their own NSArrayController
for content, and that's working fine.
What I want to happen is that the selection on #1 drives the enabled/
disabled property on the other.
I have a value transformer registered and working, at least
initially. It looks at the item selected in the first button and
returns an NSNumber yes/no to drive the enabled property on the
second button.
After the code that programmatically binds the contents of both
buttons, I have this:
[secondPopupButton bind:@"enabled"
toObject:firstPopupButtonArrayController
withKeyPath:@"selectedObjects"
options:[NSDictionary
dictionaryWithObjectsAndKeys:
@"MyValueTransformer",
NSValueTransformerNameBindingOption,
[NSNumber numberWithBool:YES],
NSContinuouslyUpdatesValueBindingOption]];
I have an NSLog in my value transformer. On awakeFromNib, I get the
log message, but then never get it again when the first button's
selection is changed, so naturally, the second button's enabled/
disabled state never changes.
I tried adding the second button as an observer to the first button's
array controller. Nada.
I then tried subclassing the second button to put in my own call to
observeValueForKeyPath:ofObject:change:context: -- also nothing.
Where am I going wrong?
--
Justin R. Miller
Code Sorcery Workshop
http://codesorcery.net
_______________________________________________
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