• 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: Greg Titus <email@hidden>
  • Date: Thu, 30 Aug 2001 09:43:12 -0700

On Thursday, August 30, 2001, at 08:33 AM, Douglas Davidson wrote:

This is somewhat similar. You want the textview to act like a field
editor, as above, except that you want return to be bound to
insertNewlineIgnoringFieldEditor:, something that otherwise you would
get with option-return. There may be a way to do this without
subclassing, but I can't think of one right now. You could subclass,
override insertNewline:, and check [NSApp currentEvent] to see if it is
an unmodified return; if it is, call [super
insertNewlineIgnoringFieldEditor:sender], and if not just call [super
insertNewline:sender].

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;
}

--Greg


  • Follow-Ups:
    • Re: Return and Enter keys in NSTextView
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: Return and Enter keys in NSTextView (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: Wrapping my head around views/cells...
  • Next by Date: Re: Return and Enter keys in NSTextView
  • Previous by thread: Re: Return and Enter keys in NSTextView
  • Next by thread: Re: Return and Enter keys in NSTextView
  • Index(es):
    • Date
    • Thread