• 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: How to control the commit of text edit field with binding?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to control the commit of text edit field with binding?


  • Subject: Re: How to control the commit of text edit field with binding?
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 5 May 2006 17:35:46 +0100

So you have a text field bound to the shared defaults controller. At the moment, whatever you type in the field instantly gets saved to the defaults, but you don't want this to happen. Instead you want the new value to only be saved when the user hits the OK button?

If I have understood you correctly then, the answer is fairly simple.

1. Untick the "continuously updates value" option for the binding
2. Call commitEditing upon the defaults controller whenever you want to save the value


Mike.

On 5 May 2006, at 16:25PM0, James Bucanek wrote:

I was cleaning up my application yesterday, replacing some old- style NSNotification code with bindings; mostly as a learning exercise to learn more about bindins, not because the app was fataly flawed in any way.

I had a lot of fun, but hit one problem that I couldn't seem to solve with bindings, however it seemed so simple and command that I think it should be. I'm hoping some binding experts can shed some light on this.

I have a NSUserDefaults string property (the name the user is registed as). This is displayed in four places and edited in two. Simple, right? Just create a binding in all four places to the defaults controller and I'm done.

However, one of the places that the name is editable is in a modal sheet where the user can edit several properties then click on OK or Cancel. If I bind that text field to the defaults controller, edits to the name are commmited immediately. I don't want the changes to the field to be propogated until the user clicks the Save button, and ignored if they click Cancel.

My solution was ultimately to not bind the text field in the modal sheet. I ended up manually populating the field when the sheet opens and setting the updated value in the target message of the Save button. Is there a better way? It is possible to create a one- way binding that updates the fiel with current value but doesn't immdiately alter the model when a text field is editing? Is it possible to dictate when changes in a text field are commited?

--
James Bucanek
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


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: How to control the commit of text edit field with binding?
      • From: James Bucanek <email@hidden>
References: 
 >How to control the commit of text edit field with binding? (From: James Bucanek <email@hidden>)

  • Prev by Date: Re: NSKeyedArchiver selector not recognized
  • Next by Date: Re: Key-Value Coding Limitations
  • Previous by thread: How to control the commit of text edit field with binding?
  • Next by thread: Re: How to control the commit of text edit field with binding?
  • Index(es):
    • Date
    • Thread