Re: Is this how you can use bindings?
Re: Is this how you can use bindings?
- Subject: Re: Is this how you can use bindings?
- From: Chris Idou <email@hidden>
- Date: Wed, 13 Aug 2008 01:37:16 -0700 (PDT)
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@hidden> wrote:
> From: Ron Lue-Sang <email@hidden>
> Subject: Re: Is this how you can use bindings?
> To: "Chris Idou" <email@hidden>
> Cc: "email@hidden" <email@hidden>
> 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@hidden> 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 (email@hidden)
> >
> > 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:
> >
> >
> > This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden