How to control the commit of text edit field with binding?
How to control the commit of text edit field with binding?
- Subject: How to control the commit of text edit field with binding?
- From: James Bucanek <email@hidden>
- Date: Fri, 5 May 2006 08:25:55 -0700
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:
This email sent to email@hidden