• 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: Binding button.enabled to "NSTextField is not empty"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding button.enabled to "NSTextField is not empty"


  • Subject: Re: Binding button.enabled to "NSTextField is not empty"
  • From: mmalcolm crawford <email@hidden>
  • Date: Tue, 26 Apr 2005 10:17:40 -0700


On Apr 26, 2005, at 6:24 AM, Johnny Deadman wrote:
On 26-Apr-05, at 1:22 AM, Andrew White wrote:
I have a button. In the same window, I have a text field. I want the button's 'enabled' state to track the whether the text field is non-empty (you can only click the button if the text field has something in it).

you either need to subclass or add a category to NSTextField which has a
-(BOOL) isEmpty
method.
You then need to set 'isEmpty' whenever the status of the textfield changes.
You then create an NSObjectController to control the textfield object.
You can then bind your button's 'enabled' binding to the textfield's 'isEmpty' property via the controller.


Sorry, no, don't do this.

The correct thing to do is to bind the button's enabled state to the same property as the text field's value (using a value transformer if necessary).

Views bind to controllers which bind to models (with the major exception of WebView...). You *don't* bind to the contents of a simple view such as a text field.

mmalc

_______________________________________________
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: Binding button.enabled to "NSTextField is not empty"
      • From: John Brownlow <email@hidden>
References: 
 >Binding button.enabled to "NSTextField is not empty" (From: Andrew White <email@hidden>)
 >Re: Binding button.enabled to "NSTextField is not empty" (From: Johnny Deadman <email@hidden>)

  • Prev by Date: Re: Workaround for ABPeoplePickerValueSelectionDidChangeNotification bug?
  • Next by Date: Re: Address Book-like Window Menu
  • Previous by thread: Re: Binding button.enabled to "NSTextField is not empty"
  • Next by thread: Re: Binding button.enabled to "NSTextField is not empty"
  • Index(es):
    • Date
    • Thread