RE: Bindings making NSNumberFormatter strange
RE: Bindings making NSNumberFormatter strange
- Subject: RE: Bindings making NSNumberFormatter strange
- From: Lee Ann Rucker <email@hidden>
- Date: Thu, 23 Apr 2009 22:22:06 -0700
- Acceptlanguage: en-US
- Thread-topic: Bindings making NSNumberFormatter strange
________________________________________
From: Keary Suska [email@hidden]
Sent: Thursday, April 23, 2009 2:04 PM
To: Lee Ann Rucker
Cc: Cocoa-Dev (Apple)
Subject: Re: Bindings making NSNumberFormatter strange
On Apr 23, 2009, at 2:25 PM, Lee Ann Rucker wrote:
>> 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.
Just to be clear, are you saying that you can do field filtering with
a formatter, with appropriate undo support, without bindings, or are
you making a general remark about difficulties when using bindings
with formatters?
----
Two separate issues, both related to the fact that formatters that do filtering just aren't very robust.
I never got undo to work with a formatter, with or without bindings; we ended up disabling it because it behaved so badly. For example, if you type two characters but one gets filtered out so there's only one left in the field, then try to undo, it tries to remove two characters and gives you a range error. It ought to be simple to fix, but too much of the action happens before developer code has a chance to intercept it.
Bindings + formatters had the problem I mentioned farther down, but at least the users don't notice if you don't have bindings._______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden