• 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: Jesse Grosjean <email@hidden>
  • Date: Fri, 23 Mar 2007 17:13:53 -0400

Ken,

Thanks that helps a lot. I was starting to figure this out, but now I'm no longer guessing.

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

Here's where I found that:

"For its instances to participate in key-view loops, a custom view must return YES from canBecomeKeyView. This happens automatically if it returns YES from acceptsFirstResponder."

http://developer.apple.com/documentation/Cocoa/Conceptual/ EventOverview/HandlingKeyEvents/chapter_6_section_5.html

Thanks again for the example case, I forgot about full keyboard access.

Jesse

On Mar 23, 2007, at 4:59 PM, Ken Ferry wrote:

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


References: 
 >acceptsFirstResponder vrs canBecomeKeyView (From: Jesse Grosjean <email@hidden>)
 >Re: acceptsFirstResponder vrs canBecomeKeyView (From: "Ken Ferry" <email@hidden>)

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