• 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: NSTextView and nextKeyView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView and nextKeyView


  • Subject: Re: NSTextView and nextKeyView
  • From: Mason Mark <email@hidden>
  • Date: Fri, 26 Oct 2001 12:17:16 -0700

This thread is a little bit old, but I was just recently fixing this problem in our app (the problem where you have to tab twice to get to the next view from an NSTextView, even if you've called -setFieldEditor:YES and set the next key view).

I don't quite know what is going on (and I am curious, if anybody happens to know), but there's a workaround that works for me.

It looks like at run time, [myTextView nextKeyView] always returns an NSScroller object--sometimes the one associated with the text view (assuming it has one), and other times some different address (seems weird!).

This happens even if I set the nextKeyView to the desired view in Interface Builder, and it happens even if I re-set the text view's nextKeyView in the -awakeFromNib method of the window controller. So, it seems to me that somewhere the nextKeyView is getting set to an NSScroller after it passes out of my control.

I'm not sure who, what, or why, but I just figured tabbing between NSTextView views using -nextKeyView was not supported. So to work around this behavior, we do something like the following in the -textDidEndEditing: delegate method:

- (void)textDidEndEditing:(NSNotification *)notification {
// notification will give the reason why text did end editing (see NSText.h)
int reason = [[[notification userInfo] objectForKey:@"NSTextMovement"] intValue];
if (reason == NSTabTextMovement || reason == NSReturnTextMovement) {
[[self window] makeFirstResponder:theViewThatShouldBeNext];
}
}

Of course, you need to look at the text view ([notification object]) and figure out what theViewThatShouldBeNext needs to be...

--
Mason


On Sunday, October 14, 2001, at 09:50 AM, Doug Brown wrote:
I have a very simple problem that I'd like to fix. It seems that the
nextKeyView doesn't apply to NSTextView because when you press tab, an
actual tab goes into the text inside it (of course, this is the desired
effect for most people). However, I have it set so that the NSTextView
is not editable, but it is selectable. I'd like to be able to press tab
to switch to the nextKeyView like NSTextField works. How would I do
that? Thanks,

Douglas Davidson <email@hidden> wrote:
Try

[myTextView setFieldEditor:YES];

and see if that does what you want.

Doug Brown wrote:
Thank you! This worked! I don't see how I missed that in the NSTextView
documentation. One small problem though - I have to press tab twice to
get the focus to move to the nextResponder. Do you have any idea why it
does this, and how I could possibly fix it? I've checked my connections
in Interface Builder, and everything looks to be ok.


On Monday, October 15, 2001 2:49 PM -0700 Douglas Davidson <email@hidden> wrote:
I'm not sure what's happening here, but I would suggest that you check
to see what the window thinks its first responder is after you the first
tab is pressed.


References: 
 >Re: NSTextView and nextKeyView (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: Sheets in Cocoa
  • Next by Date: Re: Changing Desktop picture from Cocoa app in 10.1 without re-starting Finder [Success!]
  • Previous by thread: Re: NSTextView and nextKeyView
  • Next by thread: switching to r00t
  • Index(es):
    • Date
    • Thread