• 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: Alex Clarke <email@hidden>
  • Date: Tue, 26 Apr 2005 16:12:17 +1000

Andrew,

Bindings don't really work like that. You need to bind a view to a model, not to a view.
Sounds like you really need to go and read the docs.


For instance in your case you would have an NSString instance variable somewhere in a model class which stores the value of that text field, say as the "myName" ivar of some object.

Then you have some accessors in that model object such as

-(NSString *)myName;
-(NSString *)setMyName;

Read the docs on KVC....

Anyhow, once you have done the "plumbing" you will be able to bind the enabled value to whether or not your model has a value for that ivar.

Then you just need to work out how the user typing in the text field creates a new instance of your model class...

Cheers,

Alex


On 26/04/2005, at 3:22 PM, 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).


I've found the button's 'enabled' binding, but can't figure out what to put in the fields. What exact steps are required to make this work? Do I need a subclass of NSWindowController (or other object) to act as a data model?

Thanks

-- Andrew White

----------------------------------------------------------------------- ---
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
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





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

  • Prev by Date: Binding button.enabled to "NSTextField is not empty"
  • Next by Date: determining front most document?
  • Previous by thread: Binding button.enabled to "NSTextField is not empty"
  • Next by thread: Re: Binding button.enabled to "NSTextField is not empty"
  • Index(es):
    • Date
    • Thread