Re: Trivial Bindings question
Re: Trivial Bindings question
- Subject: Re: Trivial Bindings question
- From: Ricky Sharp <email@hidden>
- Date: Thu, 11 Aug 2005 16:30:25 -0500
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:
This email sent to email@hidden