Validating in a formatter
Validating in a formatter
- Subject: Validating in a formatter
- From: Darrin Cardani <email@hidden>
- Date: Mon, 23 Feb 2004 16:43:05 -0600
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.