Re: Validating in a formatter
Re: Validating in a formatter
- Subject: Re: Validating in a formatter
- From: Daniel Todd Currie <email@hidden>
- Date: Mon, 23 Feb 2004 16:20:24 -0800
I'd be interested to take a look at your formatter code, if you don't
mind; it seems like a relatively simple formatter, but perhaps there
are some nuances I don't anticipate.
If you are generally having trouble with or are unfamiliar with
formatters, there is a nice simple example here:
http://www.lumacode.com/simon/developer.html
-- Daniel Currie
On 2004 Feb 23, at 14:43, Darrin Cardani wrote:
I am attempting to write an NSFormatter that allows the user to enter
SMPTE timecodes. This formatter is being used in an NSTableView, where
the cells hold an NSString containing a QuickTime TimeValue. I
currently have it working for display, but not validation. It can
convert the TimeValue into a SMPTE string using the QuickTime TimeCode
functions.
I've added a -isPartialStringValid:newEditingString:errorDescription:
method, but I'm confused about what it's supposed to return in various
cases. If the user has typed something invalid, it obviously needs to
return NO and set the error string as appropriate. But if the user
types something valid, I'm not sure what I'm supposed to return. If
they, for example, copy and pasted a complete SMPTE timecode into the
field, I'd return YES, and not put anything into the new editing
string. However, they're usually typing in a value. They might type
something like "1234", which I would like to mean the timecode
"00:00:12:34". I am able to take the string "1234" and properly
convert it to "00:00:12:34". However, should I return NO, and set the
new string to the SMPTE timecode I constructed? Or should I return YES
and set it to the SMPTE timecode string? Or should I convert the
timecode I construct into a QuickTime TimeValue and return that as the
string? And if I do that, should I return YES or NO? The docs seem to
leave out this case.
I'd also like to allow the user to type 1 number at a time and have
the numbers move up in the timecode. So if they typed "1", they'd see
"00:00:00:01". Then when they typed "2", it would display
"00:00:00:12", etc. My attempts so far at trying various combinations
of returning YES and NO with a SMPTE string or a TimeValue string have
resulted in incorrect behavior in every case, so I'm sure I'm missing
something.
Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.