• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Return and Enter keys in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Return and Enter keys in NSTextView (From: Greg Titus <email@hidden>)

  • Prev by Date: Re: Return and Enter keys in NSTextView
  • Next by Date: Re: NSCursor and 1 bit mask ?
  • Previous by thread: Re: Return and Enter keys in NSTextView
  • Next by thread: Re: Return and Enter keys in NSTextView
  • Index(es):
    • Date
    • Thread