understand addSubview and Tab
understand addSubview and Tab
- Subject: understand addSubview and Tab
- From: "Simon Strandgaard" <email@hidden>
- Date: Thu, 25 Jan 2007 11:30:40 +0100
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?
I have read the event-handling guide, but I still don't get it.
http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/chapter_6_section_5.html#//apple_ref/doc/uid/10000060i-CH7-SW9
In the rebuild method, I have tried
if(last) [last setNextKeyView:v];
last = v;
but Tab still does nothing.
I appreaciate your suggestions.
--
Simon Strandgaard
prompt> cat TestView.h
#import <Cocoa/Cocoa.h>
@interface TestView : NSView
-(IBAction)buttonAction:(id)sender;
@end
prompt> cat TestView.mm
#import "TestView.h"
@implementation TestView
-(void)awakeFromNib {
[self rebuild];
}
-(void)rebuild {
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];
}
}
-(IBAction)buttonAction:(id)sender {
[self removeSubviews];
[self rebuild];
}
-(void)removeSubviews {
id thing;
NSEnumerator *en = [[self subviews] objectEnumerator];
while(thing = [en nextObject]) {
[thing removeFromSuperview];
}
}
@end
_______________________________________________
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