• 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: understand addSubview and Tab
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: understand addSubview and Tab


  • Subject: Re: understand addSubview and Tab
  • From: "Simon Strandgaard" <email@hidden>
  • Date: Thu, 25 Jan 2007 13:23:02 +0100

On 1/25/07, Simon Strandgaard <email@hidden> wrote:
When my program starts up then Tab changes focus to next textfield.
When invoking the buttonAction then Tab no longer has any effect.

What does it take to get Tab working?

Realized that Tab did not work because the last control had focus, so it had no nextkeyvview. However Shift-Tab works.

Now the really weird thing is that the tab-order is reversed
when the program launches, and normal when buttonAction has been invoked.

What is the difference between awakeFromNib and buttonAction?

Is there some "intelligent" setNextKeyView algorithm that only
operates right after awakeFromNib?


-(void)awakeFromNib { [self removeSubviews]; [self rebuild]; }

-(IBAction)buttonAction:(id)sender {
	[self removeSubviews];
	[self rebuild];
}

-(void)rebuild {
	NSView* last = nil;
	NSView* first = nil;
	for(int i=0; i<4; ++i) {
		NSRect frame = NSMakeRect(0.f, 30.f * i, 150.f, 30.f);
		NSView* v = [[NSTextField alloc] initWithFrame:frame];
		[self addSubview: v];

		if(i == 0) first = v;
 		if(last) [last setNextKeyView:v];
		last = v;
	}
	[last setNextKeyView:first];
	[[self window] makeFirstResponder: first];
}


Any ideas to whats going on after awakeFromNib ?


-- Simon Strandgaard http://opcoders.com/ _______________________________________________

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: 
 >understand addSubview and Tab (From: "Simon Strandgaard" <email@hidden>)

  • Prev by Date: Re: Change current process priority
  • Next by Date: Re: Completely broken XCode
  • Previous by thread: understand addSubview and Tab
  • Next by thread: Completely broken XCode
  • Index(es):
    • Date
    • Thread