Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

paos

macrumors newbie
Original poster
Aug 13, 2009
15
0
Hi:

I have two simple views which are displayed in a window, the first one has a button with this action:

Code:
-(void)botonSelector:(id)sender
{
	SecondView *testview = [[SecondView alloc] initWithFrame:NSZeroRect];
	[[self window] setContentView:testview];
	[testview release];
}

It works ok, but on the second view I have two textfields and I use this on init:

Code:
[[self window] makeFirstResponder: myTextField];

and myTextField doesnt appear selected, when I select it with the mouse I can edit it but , I can't move to the next textField using Tab on keyboard, I dont know wath I'm missing, please help.
 
Hi Paos
Try to make a close look into the Interface Builder again.
The reason that it does not work may be that the connections in the IB are not specified or are wrongly specified. Please go through each element in your window and check the connections.
I have some running examples at home and I will look at it when back home tonight. Maybe then I can give you more help.
 
After checking my connections I realized that Tab works after pressing Ctrl-Tab, any idea why is this happening?? thanks!
 
It works ok, but on the second view I have two textfields and I use this on init:
Most likely the nib hasn't yet been created yet at the init method, so you would either need to force it to load immediately, or put your code in the awakeFromNib method.
 
It seems strange.... I do not know about your program but in my case I have a NSView and three NSTextFields.

Here is what I do:
For the NSView I do run
NSResponder *resp = [[self window] firstResponder];
when the NSView is created.

Implement in the NSView handling of

- (BOOL)acceptsFirstResponder
- (BOOL)resignFirstResponder
- (BOOL)becomeFirstResponder

In the Interface builder I have to specify the
nextKeyView in serial connection, it means that NSView object points to the First NSTextView, then first NSTextView nextKeyView point into the Second NSTextView... and so on.

Hope it will explain the mechanism.
Good luck
/petron
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.