> We really recommend looking at the approach I described earlier using > NSFormatter subclass for input validation.
Unfortunately, I am not actually formatting or validating anything so this isn't helpful for me. I am working on a middle-layer framework and what I am interested in is the text change notification with enough information about how the string just changed. shouldChangeTextInRange:replacementString: provides me the level of detail I am interested in. > All NSControl subclass hosting a field editor is a text view delegate. > You can simply override the delegate method with your custom NSTextField > subclass. > For example, > > - (BOOL)textView:(NSTextView *)aTextView > shouldChangeTextInRange:(NSRange)aRange replacementString:(NSString > *)aString { > if ([super textView:aTextView shouldChangeTextInRange:aRange > replacementString:aString]) { > id delegate = [self delegate]; > if ([delegate > respondsToSelector:@selector(textView:shouldChangeTextInRange:replacementString:)]) > return [delegate textView:aTextView shouldChangeTextInRange:aRange > replacementString:aString]; > return YES; > } > > return NO; > } > > should give you essentially what you want. Drat, this was the first thing I tried and I never got the callback which is why I went down the whole field handler path. I just tried it again, and it just worked. I'm still a bit confused/overwhelmed by this whole thing, like how the delegate can call [super textView:aTextView shouldChangeTextInRange:aRange replacementString:aString]). The delegate isn't necessarily a subclass of NSTextView, right? Also, for the record, I figured out why my DidBegin callback didn't fire. I forgot to call super in my shouldChangeTextInRange:replacementString: method of my subclass of NSTextView for the field handler. But regardless, I'm deleting all my field handler stuff and just going with the delegate now that it works for me. Thanks, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com