Re: Return and Enter keys in NSTextView
Re: Return and Enter keys in NSTextView
- Subject: Re: Return and Enter keys in NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Thu, 30 Aug 2001 09:50:52 -0700
On Thursday, August 30, 2001, at 09:43 AM, Greg Titus wrote:
Instead of subclassing, you could be the NSTextView's delegate and
implement -textView:doCommandBySelector: to do essentially the same
thing...
- (BOOL)textView:(NSTextView *)aTextView
doCommandBySelector:(SEL)aSelector;
{
if (aSelector == @selector(insertNewline:) && ([NSApp
currentEvent] ... is an unmodified return ...)) {
[aTextView insertNewlineIgnoringFieldEditor:self];
return YES;
}
return NO;
}
Good point. I was trying to think of a way to do this without having to
look at currentEvent, but by the time we get to doCommandBySelector, we
have divorced the command from any event that might have generated it,
whereas before we enter the key-binding mechanism, we don't a priori
know what command it will end up generating. So this may be the best we
can do.
Douglas Davidson