// // CFgTextField.m // FgTextField // // Created by Francesco Germinara on Fri Jun 04 2004. // Copyright (c) 2004 __MyCompanyName__. All rights reserved. // #import "CFgTextField.h" @implementation CFgTextField - (id)init { self=[super init]; nMaxLength=2; bUpper=FALSE; return(self); } -(void)SetLimitText:(int) maxChars{ nMaxLength=maxChars; } -(void)SetOnlyUpper:(BOOL) sts{ bUpper=sts; } - (void)keyDown:(NSEvent *)theEvent { [super keyDown:theEvent]; } //Modifico il contenuto del campo in base alle impostazioni - (void)didChangeText { NSString *strFit; strFit=[self string]; if(bUpper) strFit=[strFit uppercaseString]; if([strFit length] > nMaxLength){ strFit=[strFit substringToIndex:nMaxLength]; NSBeep(); } [self setString:strFit]; [super didChangeText]; } @end