On Apr 23, 2009, at 8:20 AM, Keary Suska wrote:

On Apr 22, 2009, at 6:24 PM, Ulai Beekam wrote:

So I really must make a custom field editor to accomplish on-the-fly
validation (i.e. disallowing on-the-fly invalid characters)?

It is not your only choice, but it is probably the best choice.
Another poster suggested using isPartialStrignValid of the formatter,
but I have tried this in the past and run into undo issues,
particularly when using it to "filter" input. The problem is that undo
registration happens before the validation call, and somehow the "undo
typing" feature remembers the string, so when you change the string in
the validator method, and then undo, you can get add results and out-
of-bounds exceptions. Since then I haven't looked into why this
happens and how to get around it, if at all possible.


There's no workaround. I tried writing my own Undo handler, but as you've discovered the changes happen before there's a chance to handle them.

Formatters work, and bindings work, but the combination doesn't. The only solution I've found is to use a formatter without bindings, since having the formatter is more important than having bindings, useful as they may be.

The whole thing just seems strange to me. Because when the text
field is not bound, on-the-fly validation seems to work just fine!
But this great feature goes away as soon as the text field is bound.
That is, as soon as the text field is bound, the validation stops
being on-the-fly and goes elsewhere instead. Is there no way having
the validation ALSO as an on-the-fly thing? Hmmmm.

I am not sure what you are describing here. Did you check
"continuously updates value" in the binding?


Radar bug 5293557 (filed June 2007, never updated): If I attach an NSFormatter to an NSTextField that has a binding set to continuously update values, the bound value gets updated the first time something is typed into the field, but not thereafter.

It appears to be changing the string directly without going through any normal accessors.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to