I put txt1(NSTextFiled),txt2 (NSTextField) , tbl1 (NSTableView) on view1,when cursor is in txt1,I push TAB key and cursor goes to txt2.i want to change it from code that when i push TAB i go to tbl1 (tbl1 becomes first responder), then i subclass txt1 to customtext
and implement below code in it
- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector
{
BOOL result = NO;
if (commandSelector == @selector(insertTab:))
{
[self.delegate performSelector:@selector(pressTAB) withObject:nil ];
}//if
. . .
}
and i implement pressTAB
method in view1 and write below code
-(void)pressTAB
{
[[self.view window] makeFirstResponder:self.tbl1];
}
everything is ok and code works properly but after this code run Xcode automatically change first responder to txt2. how can i disable automatic TAB change and just do it from my code ?
You can do this in code by setting the nextKeyView property (using Xcode 4.2 it doesn't seem to work to do this in IB). So:
txt1.nextKeyView = tbl1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.