Re: Binding button.enabled to "NSTextField is not empty"
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