• 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: Implementing key view loop in custom NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing key view loop in custom NSView


  • Subject: Re: Implementing key view loop in custom NSView
  • From: Keith Blount <email@hidden>
  • Date: Mon, 10 Aug 2009 05:34:10 -0700 (PDT)

You should be able to do this with a combination of -becomeFirstResponder, -acceptsFirstResponder, -setNextResponder. If B isn't supposed to be the first responder at all, then it should return NO for -acceptsFirstResponder (but its subviews x and y should return YES).

Then, in the superview that holds A, B and C, you could do something lie the following after you have set up the view hierarchy:

[A setNextResponder:[B x]];
[[B x] setNextResponder:[B y]];
[[B y] setNextResponder:C];
[C setNextResponder:A];

(The above assumes that subview B has methods -(NSView *)x and -(NSView *)y to return its subviews, of course).

If you're adding the subviews in IB, of course, you could just hook it all up there and avoid the code altogether.

All the best,
Keith

> I am wondering whats the best approach to handle the key view loop in a
> custom NSView that consists of several sub-views that the user can tab
> between?
>
> Lets say I have three views A, B, and C, all chained up in that order in
> the key view loop. if B is my custom view consisting of subviews B.x and
> B.y, then I want the key view to go like A -> B.x -> B.y -> C.
>
> My current thinking is to override - (BOOL)becomeFirstResponder to change
> first responder to B.x when B becomes first responder and to set the next
> key view of B.y to the next key view of B.
>
> Is this how it's supposed to be done?
>
> / Andreas



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: Implementing key view loop in custom NSView
      • From: Andreas Eriksson <email@hidden>
  • Prev by Date: Re: Testing if a NSPipe has available data
  • Next by Date: Re: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?
  • Previous by thread: Re: Implementing key view loop in custom NSView
  • Next by thread: Re: Implementing key view loop in custom NSView
  • Index(es):
    • Date
    • Thread