self-validating text fields
self-validating text fields
- Subject: self-validating text fields
- From: Mike Abdullah <email@hidden>
- Date: Mon, 27 Mar 2006 23:52:04 +0100
Dear list,
In my app, I have a text field that is bound to a particular key of
its data model.
This binding uses a transformer that in normal transformation, takes
the data model's data and converts it to a string. When performing
the reverse transformation, the transformer evaluates the string in
the text field and produces the data from it.
Now here's the thing, I want my text field to "validate" itself (I
have a feeling that is the wrong term to use here). So, if the user
enters nothing into the field, when they end editing of it (either by
hitting return or changing the first responder) if changes back to
its original value.
Similarly, upon entering a valid string into the field, and ending
editing, I want the field to set its contents to the properly
formatted version of what the user just entered.
Now, I have managed to do this, but it is currently very messy. I
have set my data controller to be the fields delegate, and when the
field ends editing, the controller does this:
[dataModel setDataKey: [dataModel dataKey]];
This was the only way after much experimentation that I could find to
force the binding of the text field to apply the transformer again.
I'm sure there has to be an easier way than this. Any sugestions?
Mike.
_______________________________________________
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