Bindings and nested checkboxes and enabled

2009-03-15 Thread Adam Gerson
I have two checkboxes in a preferences window which are bound to user
defaults. The second checkbox should only be enabled if the first
checkbox its true. I have this working great with bindings. The second
checkboxe's enabled binding is bound to the value of the first one.
However, if the first checkbox becomes false, the second checkbox goes
unenabled, but remains checked. Is there any way with bindings to get
the second checkbox to reset to false when the first checkbox is
unchecked. I can't bind them both to the same value because there are
cases when the first checkbox would be true and the second one would
be false.

If you need a visual:

http://screencast.com/t/BbQOybP2KjN


Thanks,
Adam
___

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


Re: Bindings and nested checkboxes and enabled

2009-03-15 Thread Andrew Merenbach


On Mar 15, 2009, at 8:41 PM, Adam Gerson wrote:


I have two checkboxes in a preferences window which are bound to user
defaults. The second checkbox should only be enabled if the first
checkbox its true. I have this working great with bindings. The second
checkboxe's enabled binding is bound to the value of the first one.
However, if the first checkbox becomes false, the second checkbox goes
unenabled, but remains checked. Is there any way with bindings to get
the second checkbox to reset to false when the first checkbox is
unchecked. I can't bind them both to the same value because there are
cases when the first checkbox would be true and the second one would
be false.

If you need a visual:

http://screencast.com/t/BbQOybP2KjN


Thanks,
Adam


Hi, Adam,

You'll probably want to set up a target-action method to do this,  
rather than trying to get a pure-bindings solution.  The enabling can  
be done with bindings, certainly, but you can  the act of resetting  
the checked state will likelyrequire a call to -[NSButton setState:]  
with a parameter of NSOffState from an IBAction called from the first  
checkbox.  Hope this helps!


Cheers,
Andrew

___

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


Re: Bindings and nested checkboxes and enabled

2009-03-15 Thread Kyle Sluder
The logical answer is for some object in your application (probably
your application delegate) to observe the first property using KVO and
update the second property accordingly.  After all, don't you want to
update the second default anyway when the first changes?  You also
should be binding your second checkbox's enabled property to the same
keypath as the first checkbox's value; bindings are usually done from
view to controller, not view to view.

--Kyle Sluder
___

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