Ahh I see. That works for a button, but with a toolbar button it makes the 
button flash momentarily, but then stays non-enabled. Any ideas?



--- On Tue, 8/12/08, Ron Lue-Sang <[EMAIL PROTECTED]> wrote:

> From: Ron Lue-Sang <[EMAIL PROTECTED]>
> Subject: Re: Is this how you can use bindings?
> To: "Chris Idou" <[EMAIL PROTECTED]>
> Cc: "cocoa-dev@lists.apple.com" <cocoa-dev@lists.apple.com>
> Date: Tuesday, August 12, 2008, 11:56 PM
> The way to think about this is, you bind the value of the
> text field  
> to a controller (or model) object that owns the value.
> Then, bind the  
> enabled binding of the button to the same property of of
> the same  
> controller and use a valuetransformer to check whether the
> value is nil.
> 
> So your setup should look like:
> - TextField value binding bound to yourObject with keypath 
> 
> yourStringProperty
> - button enabled binding bound to yourObject with keypath  
> yourStringProperty with value transformer NSIsNotNil
> 
> You may want to turn on "continuously updates
> value" for the  
> textfiled's value binding.This way as soon as the user
> starts typing,  
> the enabled state of the button will get toggled.
> 
> Note that part of why this works with the value transformer
> is because  
> the textfield value binding sets nil as the value when the
> textfield  
> is emptied.
> 
> ---------------------
> RONZILLA
> 
> On Aug 12, 2008, at 11:21 PM, Chris Idou
> <[EMAIL PROTECTED]> wrote:
> 
> > I want a button to be enabled when myTextField is not
> empty.
> >
> > Can have an outlet in my controller called
> myTextField, and then set  
> > the "Enabled" binding on the button to point
> to  
> > myTextField.stringValue.length, then can I write a
> transformer  
> > called GreaterThanZero to return boolean if the input
> is greater  
> > than zero?
> >
> > Is that a valid way to go about this problem? It
> doesn't seem to be  
> > working for me. I wrote a myTextField accessor to see
> what is  
> > happening and it doesn't even seem to get called.
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator
> comments to the list.
> > Contact the moderators at
> cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> >
> http://lists.apple.com/mailman/options/cocoa-dev/luesang%40apple.com
> >
> > This email sent to [EMAIL PROTECTED]


      
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to