• 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: how do I get the "key" sub view of a window?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how do I get the "key" sub view of a window?


  • Subject: Re: how do I get the "key" sub view of a window?
  • From: Mike Ferris <email@hidden>
  • Date: Tue, 10 Dec 2002 11:28:54 -0800

The reason the first responder is an NSTextView and not one of your NSTextFields is because of the way that Cocoa implements editable NSTextFields. It uses a "field editor" (ie an instance of NSTextView that is temporarily inserted in the window on top of the text field to handle the editing.)

One trick you can use to figure out if the first responder is a "field editor" and what control it is editing on behalf of is to check:

- Is the first responder an NSTextView?
- If it is, does -isFieldEditor return YES?
- If it does, the delegate of the NSTextView will be the control it is editing on behalf of.

Mike

Begin forwarded message:

From: Nicholas Riley <email@hidden>
Date: Tue Dec 10, 2002 4:24:08 AM US/Pacific
To: Donald Hall <email@hidden>
Cc: email@hidden
Subject: Re: how do I get the "key" sub view of a window?

On Tue, Dec 10, 2002 at 12:15:44AM -0700, Donald Hall wrote:
However, [mywindow firstResponder] returns an NSTextView, presumably the
content view of the window.

NSTextView does not accept the message firstResponder.

I'm sure I must be missing something easy, but I couldn't find anything
in the documentation that would do what I want.

Actually not obvious at all, although IMO this should be very easy to do.

<http://cocoa.mamasam.com/COCOADEV/2002/03/2/28501.php>

So you'd do something like this:

if ([field1 currentEditor] != nil) {
[field1 selectText: self];
} else if ([field2 currentEditor != nil) {
[field2 selectText: self];
}

--
=Nicholas Riley <email@hidden> | <http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: how do I get the "key" sub view of a window? (From: Nicholas Riley <email@hidden>)

  • Prev by Date: Re: Subclassing NSWindowController
  • Next by Date: Re: How to draw a horizontal line in a NSTextView?
  • Previous by thread: Re: how do I get the "key" sub view of a window?
  • Next by thread: Re: how do I get the "key" sub view of a window?
  • Index(es):
    • Date
    • Thread