Re: Intelligent NSFormatter
Re: Intelligent NSFormatter
- Subject: Re: Intelligent NSFormatter
- From: Keary Suska <email@hidden>
- Date: Fri, 15 Sep 2006 10:51:45 -0600
- Thread-topic: Intelligent NSFormatter
on 9/14/06 1:14 PM, email@hidden purportedly said:
> * The text field should display the date as text using the user's
> NSShortDateFormatString preference
>
> * As the user types, if a valid date is entered, the field should
> change its text to the default way of displaying the date (I'm not
> entirely sure about this one yet!)
>
> * If the user ends editing of the text field without entering a valid
> date, the text field should revert to the last valid date they entered.
>
> So, is this possible with NSFormatter and NSValueTransformer (and
> that therefore I've missed something), or do I need a different
> method. If so, what would people recommend?
All of this is possible using NSFormatter, but not NSValueTransformer, since
the latter is only called when the binding needs to update the value.
I have been able to do all of this satisfactorily *except* for the second
item ("As the user types ..."). I could get it to work but it completely
fouled when undo gets into the mix. I think I posted about this, but
received no responses. I gave up on formatting-as-you-type and did my
formatting on exit.
In theory, "live" formatting isn't too difficult, you would use
-isPartialStringValid:proposedSelectedRange:originalString:originalSelectedR
ange:errorDescription:. Some of the gotchas involve the user deleting
characters, including that the "delete" key doesn't change the insertion as
expected. It either increments or decrements the insertion point--I don't
recall exactly which--when it should not change the insertion at all.
I you figure out how to do this with undo support I would really like to
know how you solved it.
Best regards,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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