[Biococoa-dev] strider and gck format
Koen van der Drift
kvddrift at earthlink.net
Mon Mar 20 17:25:30 EST 2006
On Mar 20, 2006, at 5:04 AM, Alexander Griekspoor wrote:
> 'm not sure if you can use a formatter in combination with a
> textview, I thought only with a textfield (update, just checked.
> setformatter: indeed only works with NSCell, but perhaps you could
> set it on the fieldeditor. probably also not, because that one is
> also of class NSText).
Yep, I found that out a little bit after doing some more reading :(
Anyway, with shouldChangeTextinRange it is very easy to do:
- (BOOL)textView:(NSTextView *)aTextView
shouldChangeTextInRange:(NSRange)affectedCharRange
replacementString:(NSString *)replacementString
{
if ([[self protein] validateInput: replacementString])
{
editedRange = affectedCharRange;
[[self protein] changeSequenceStringInRange: editedRange
withString: newString]; // this needs some more attention
return YES;
}
return NO;
}
and in validateInput:
- (BOOL)validateInput: (NSString *)aString
{
return [[self symbolSet] containsCharactersFromString: aString];
}
- Koen.
More information about the Biococoa-dev
mailing list