如何从控件获取nstextfield:textView:doCommandBySelector

时间:2018-06-14 08:15:47

标签: nstextfield

我有6个文本字段,我想知道对此方法的哪个字段响应 我无法将textView传输到textfield,我该怎么办?

(BOOL)control:(NSControl *)control
   textView:(NSTextView *)textView
doCommandBySelector:(SEL)commandSelector{


NSLog(@"commandSelector : %@",NSStringFromSelector(commandSelector));
//insertTab:   -键入tab
//insertNewline:   -键入回车
//deleteBackward

MSSingleField *field = (MSSingleField *)textView;

if ([NSStringFromSelector(commandSelector) isEqualToString:@"deleteBackward:"]) 
{

    if (field.lastKeyView) {
        [field.lastKeyView becomeFirstResponder];
    }

}

return NO;
}

1 个答案:

答案 0 :(得分:1)

control参数是文本字段。