• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trivial Bindings question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Trivial Bindings question
      • From: Scott Anguish <email@hidden>
    • Re: Trivial Bindings question
      • From: Scott Anguish <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>)

  • Prev by Date: Re: Text Field Limits and Undo
  • Next by Date: Strange Key Input Behavior
  • Previous by thread: Trivial Bindings question
  • Next by thread: Re: Trivial Bindings question
  • Index(es):
    • Date
    • Thread