我有一个TextField(IBOutlet NSTextField *commandInput;
)来获取输入作为命令,我有一个Button来通过调用此方法来运行命令:
- (IBAction) runShell: (id)sender;
{
// get the string from inputItem
NSString* item = [commandInput stringValue];
system([item UTF8String]);
NSLog(@"%s", [item UTF8String]);
}
我可以删除按钮吗?我的意思是,当我点击 TextField时,我可以运行runShell方法吗?
答案 0 :(得分:1)
是。 documentation如此明确地说:
NSTextField
对象是一种NSControl
,它显示用户可以选择或编辑的文本,并在用户在编辑时按下Return键时将其操作消息发送到目标。