Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trivial Bindings question




On Aug 11, 2005, at 12:55 PM, John Stiles wrote:

I'm just getting my feet wet with bindings.

Welcome to the wonderful world of bindings!

I want to cause an NSButton to enable/disable itself, depending on whether a neighboring NSTableView has a selection or not. I tried hooking it up in Interface Builder, but I just got exceptions when I ran it.
Is there sample code which would demonstrate this, or something reasonably similar?

I would definitely google on this and/or search the archives. I believe there are at least a couple examples on this floating around somewhere.


But, to get you started, my guess is that you'd bind NSTableView's content to an instance of NSArrayController. Then bind NSButton's enabled to something in the array controller. What is bound depends on what your button is doing. If it will add or remove an item, you could bind the button enabled state to the controller's 'canAdd' and 'canRemove' respectively.

If you need to more generally know when there is a selection, I think you could bind to the controller's selectedIndex. I think you'd then need to set up a value transformer to transform the index value into an appropriate boolean value.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Key-Observing, change, and NSNull (From: Edwin Vane <email@hidden>)
 >Re: Key-Observing, change, and NSNull (From: Edwin Vane <email@hidden>)
 >Trivial Bindings question (From: John Stiles <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.