• 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: acceptsFirstResponder vrs canBecomeKeyView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: acceptsFirstResponder vrs canBecomeKeyView


  • Subject: Re: acceptsFirstResponder vrs canBecomeKeyView
  • From: "Ken Ferry" <email@hidden>
  • Date: Fri, 23 Mar 2007 13:59:14 -0700

Hi Jesse,

The docs say that canBecomeKeyView will automatically return YES if acceptsFirstResponder is YES.

Where does it say that? That isn't correct. canBecomeKeyView should imply acceptsFirstResponder, but not the other way around.

acceptsFirstResponder controls whether a responder will accept first
responder status if it is asked (i.e. -[NSWindow makeFirstResponder:]
is called with the responder).  -[NSView canBecomeKeyView] controls
whether AppKit will ask a view to become responder in the first place.
The second calls acceptsFirstResponder, but also checks information
such as whether the view is hidden and whether full keyboard access is
on.

-[NSView canBecomeKeyView] is rarely overridden, -[NSResponder
acceptsFirstResponder] is frequently overridden.

Here's some example behavior with NSButton:

NSButton almost always returns YES to acceptsFirstResponder.  It will
return NO if, say, the button is disabled.  (NSButton doesn't override
acceptsFirstResponder, though.  NSControl delegates to [[control cell]
acceptsFirstResponder], and NSButtonCell has the above behavior.)

NSButton will return NO from canBecomeKeyView if full keyboard access
is off, otherwise usually YES.  It doesn't override the NSView level
canBecomeKeyView.  No public class in AppKit does.

The acceptsFirstResponder implementation is usually pretty simple.

Hope that helps some!

Ken Ferry
Cocoa Frameworks

On 3/22/07, Jesse Grosjean <email@hidden> wrote:
I'm trying to understand the difference between acceptsFirstResponder
and canBecomeKeyView. The docs say that canBecomeKeyView will
automatically return YES if acceptsFirstResponder is YES. But are
there cases where acceptsFirstResponder would be NO and
canBecomeKeyView would be YES?

Can someone give some examples on how they differ and what
canBecomeKeyView is needed?

Thanks,
Jesse
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: acceptsFirstResponder vrs canBecomeKeyView
      • From: Jesse Grosjean <email@hidden>
References: 
 >acceptsFirstResponder vrs canBecomeKeyView (From: Jesse Grosjean <email@hidden>)

  • Prev by Date: Re: Is there a way to re-compile a framework for Intel Mac?
  • Next by Date: Re: acceptsFirstResponder vrs canBecomeKeyView
  • Previous by thread: acceptsFirstResponder vrs canBecomeKeyView
  • Next by thread: Re: acceptsFirstResponder vrs canBecomeKeyView
  • Index(es):
    • Date
    • Thread