Re: customizing TextView keyboard responses
Re: customizing TextView keyboard responses
- Subject: Re: customizing TextView keyboard responses
- From: Mason Mark <email@hidden>
- Date: Tue, 18 Dec 2001 14:38:29 -0800
On Tuesday, December 18, 2001, at 09:04 AM, Matt Neuburg wrote:
At 11:24 AM -0500 12/18/01, Jim Correia wrote:
At 8:07 AM -0800 12/18/01, Matt Neuburg wrote:
How do I customize a TextView so that when the user types a Tab key
into
it, it tabs to the next key view (like a TextField) rather than
entering
the tab into the text? Thx - m.
<http://developer.apple.com/techpubs/macosx/Cocoa/Reference/ApplicationKit/
ObjC_classic/Classes/NSText.html#//apple_ref/occ/instm/NSText/setFieldEditor:
>
should do the trick.
No, it's more complicated than that, because I want Return characters
to be
entered as usual. I don't want a TextField; I want a TextView with just
this one customized bit of behavior. m.
If you want that behavior, you can subclass NSTextView. Call [myTextView
setFieldEditor:YES] like Jim suggested to get the default field editing
behavior.
Then, in your subclass, you can override the default behavior for
newlines by overriding -insertNewline: to call NSTextView's
-insertNewlineIgnoringFieldEditor:
- (void)insertNewline:(id)sender;
/*" Overridden to call -insertNewlineIgnoringFieldEditor:, because we
only want to tab between views, not return between views. "*/
{
[super insertNewlineIgnoringFieldEditor:sender];
}
Like it sounds, this will make your text view behave like a field editor
with respect to the Tab key, but accept newlines like any normal text
input.
Regards,
--
Mason